From 9d7c35ae4872f15682b0c0f34345ae05e1ecce90 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sun, 23 Sep 2012 00:36:20 +0200 Subject: [PATCH 001/255] and go --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwbase/windowmanager.hpp | 2 + apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 24 ++-- apps/openmw/mwgui/dialogue.cpp | 22 +++- apps/openmw/mwgui/dialogue.hpp | 12 +- apps/openmw/mwgui/list.cpp | 5 + apps/openmw/mwgui/list.hpp | 3 + apps/openmw/mwgui/mode.hpp | 1 + apps/openmw/mwgui/spellbuyingwindow.cpp | 5 +- apps/openmw/mwgui/spellbuyingwindow.hpp | 8 +- apps/openmw/mwgui/spellcreationdialog.cpp | 120 ++++++++++++++++++ apps/openmw/mwgui/spellcreationdialog.hpp | 40 ++++++ apps/openmw/mwgui/tooltips.cpp | 34 ++++- apps/openmw/mwgui/tooltips.hpp | 1 + apps/openmw/mwgui/widgets.hpp | 2 +- apps/openmw/mwgui/windowmanagerimp.cpp | 14 ++ apps/openmw/mwgui/windowmanagerimp.hpp | 5 + files/mygui/CMakeLists.txt | 1 + .../mygui/openmw_spellcreation_dialog.layout | 80 ++++++++++++ files/mygui/openmw_tooltips.layout | 25 ++++ 20 files changed, 375 insertions(+), 31 deletions(-) create mode 100644 apps/openmw/mwgui/spellcreationdialog.cpp create mode 100644 apps/openmw/mwgui/spellcreationdialog.hpp create mode 100644 files/mygui/openmw_spellcreation_dialog.layout diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 66844b2806..fabbf37499 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -29,7 +29,7 @@ add_openmw_dir (mwgui map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list formatting inventorywindow container hud countdialog tradewindow settingswindow confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu - itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog + itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 4291631363..9f251476af 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -226,6 +226,8 @@ namespace MWBase virtual bool getRestEnabled() = 0; virtual bool getPlayerSleeping() = 0; + + virtual void startSpellMaking(MWWorld::Ptr actor) = 0; }; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 1b7532d0a1..daff8c67a2 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -145,16 +145,17 @@ namespace return false; } -} - -namespace MWDialogue -{ //helper function std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) { return toLower(str).find(toLower(substr),pos); } +} + +namespace MWDialogue +{ + bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice) { @@ -779,6 +780,8 @@ namespace MWDialogue services = ref->base->mAiData.mServices; } + int windowServices = 0; + if (services & ESM::NPC::Weapon || services & ESM::NPC::Armor || services & ESM::NPC::Clothing @@ -790,14 +793,15 @@ namespace MWDialogue || services & ESM::NPC::Apparatus || services & ESM::NPC::RepairItem || services & ESM::NPC::Misc) - win->setShowTrade(true); - else - win->setShowTrade(false); + windowServices |= MWGui::DialogueWindow::Service_Trade; if (services & ESM::NPC::Spells) - win->setShowSpells(true); - else - win->setShowSpells(false); + windowServices |= MWGui::DialogueWindow::Service_BuySpells; + + if (services & ESM::NPC::Spellmaking) + windowServices |= MWGui::DialogueWindow::Service_CreateSpells; + + win->setServices (windowServices); // sort again, because the previous sort was case-sensitive keywordList.sort(stringCompareNoCase); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index a01da7f9f9..476379c5da 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -27,6 +27,8 @@ using namespace Widgets; *Copied from the internet. */ +namespace { + std::string lower_string(const std::string& str) { std::string lowerCase; @@ -42,12 +44,13 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su return lower_string(str).find(lower_string(substr),pos); } +} + DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_dialogue_window.layout", parWindowManager) , mEnabled(true) - , mShowTrade(false) - , mShowSpells(false) + , mServices(0) { // Centre dialog center(); @@ -134,7 +137,11 @@ void DialogueWindow::onSelectTopic(std::string topic) mWindowManager.pushGuiMode(GM_SpellBuying); mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); } - + else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSpellMakingMenuTitle")->str) + { + mWindowManager.pushGuiMode(GM_SpellCreation); + mWindowManager.startSpellMaking (mPtr); + } else MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); } @@ -155,14 +162,17 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords) { mTopicsList->clear(); - bool anyService = mShowTrade||mShowSpells; + bool anyService = mServices > 0; - if (mShowTrade) + if (mServices & Service_Trade) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sBarter")->str); - if (mShowSpells) + if (mServices & Service_BuySpells) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSpells")->str); + if (mServices & Service_CreateSpells) + mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.search("sSpellmakingMenuTitle")->str); + if (anyService) mTopicsList->addSeparator(); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index a43b0d5a70..8074d9b866 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -50,8 +50,14 @@ namespace MWGui // various service button visibilities, depending if the npc/creature talked to has these services // make sure to call these before setKeywords() - void setShowTrade(bool show) { mShowTrade = show; } - void setShowSpells(bool show) { mShowSpells = show; } + void setServices(int services) { mServices = services; } + + enum Services + { + Service_Trade = 0x01, + Service_BuySpells = 0x02, + Service_CreateSpells = 0x04 + }; protected: void onSelectTopic(std::string topic); @@ -73,6 +79,8 @@ namespace MWGui bool mShowTrade; bool mShowSpells; + int mServices; + bool mEnabled; DialogueHistory* mHistory; diff --git a/apps/openmw/mwgui/list.cpp b/apps/openmw/mwgui/list.cpp index 661fb2e683..ff23f8b311 100644 --- a/apps/openmw/mwgui/list.cpp +++ b/apps/openmw/mwgui/list.cpp @@ -129,3 +129,8 @@ void MWList::onItemSelected(MyGUI::Widget* _sender) eventItemSelected(name); } + +MyGUI::Widget* MWList::getItemWidget(const std::string& name) +{ + return mScrollView->findWidget (getName() + "_item_" + name); +} diff --git a/apps/openmw/mwgui/list.hpp b/apps/openmw/mwgui/list.hpp index 2b765c2e11..c1f2d83b56 100644 --- a/apps/openmw/mwgui/list.hpp +++ b/apps/openmw/mwgui/list.hpp @@ -38,6 +38,9 @@ namespace MWGui std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is void clear(); + MyGUI::Widget* getItemWidget(const std::string& name); + ///< get widget for an item name, useful to set up tooltip + protected: void initialiseOverride(); diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index 64aa1dc216..042505209b 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -22,6 +22,7 @@ namespace MWGui GM_Rest, GM_RestBed, GM_SpellBuying, + GM_SpellCreation, GM_Levelup, diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index a41869e324..3a492ce901 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -24,7 +24,6 @@ namespace MWGui SpellBuyingWindow::SpellBuyingWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_spell_buying_window.layout", parWindowManager) - , ContainerBase(NULL) // no drag&drop , mCurrentY(0) , mLastPos(0) { @@ -77,7 +76,7 @@ namespace MWGui void SpellBuyingWindow::startSpellBuying(const MWWorld::Ptr& actor) { center(); - mActor = actor; + mPtr = actor; clearSpells(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); @@ -114,7 +113,7 @@ namespace MWGui MWMechanics::Spells& spells = stats.getSpells(); spells.add (mSpellsWidgetMap.find(_sender)->second); mWindowManager.getTradeWindow()->addOrRemoveGold(-price); - startSpellBuying(mActor); + startSpellBuying(mPtr); MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); } diff --git a/apps/openmw/mwgui/spellbuyingwindow.hpp b/apps/openmw/mwgui/spellbuyingwindow.hpp index 970498cd91..1d0ac28e01 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.hpp +++ b/apps/openmw/mwgui/spellbuyingwindow.hpp @@ -1,10 +1,8 @@ #ifndef MWGUI_SpellBuyingWINDOW_H #define MWGUI_SpellBuyingWINDOW_H -#include "container.hpp" #include "window_base.hpp" - -#include "../mwworld/ptr.hpp" +#include "referenceinterface.hpp" namespace MyGUI { @@ -20,7 +18,7 @@ namespace MWGui namespace MWGui { - class SpellBuyingWindow : public ContainerBase, public WindowBase + class SpellBuyingWindow : public ReferenceInterface, public WindowBase { public: SpellBuyingWindow(MWBase::WindowManager& parWindowManager); @@ -35,8 +33,6 @@ namespace MWGui MyGUI::ScrollView* mSpellsView; - MWWorld::Ptr mActor; - std::map<MyGUI::Widget*, std::string> mSpellsWidgetMap; void onCancelButtonClicked(MyGUI::Widget* _sender); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp new file mode 100644 index 0000000000..fd5e9594c7 --- /dev/null +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -0,0 +1,120 @@ +#include "spellcreationdialog.hpp" + +#include <components/esm_store/store.hpp> + +#include "../mwbase/windowmanager.hpp" + +#include "../mwbase/world.hpp" +#include "../mwbase/environment.hpp" + +#include "../mwworld/player.hpp" +#include "../mwworld/class.hpp" + +#include "../mwmechanics/spells.hpp" +#include "../mwmechanics/creaturestats.hpp" + +#include "tooltips.hpp" +#include "widgets.hpp" + +namespace +{ + + bool sortMagicEffects (short id1, short id2) + { + return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(MWGui::Widgets::MWSpellEffect::effectIDToString (id1))->getString() + < MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(MWGui::Widgets::MWSpellEffect::effectIDToString (id2))->getString(); + } +} + +namespace MWGui +{ + + SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) + : WindowBase("openmw_spellcreation_dialog.layout", parWindowManager) + { + getWidget(mNameEdit, "NameEdit"); + getWidget(mMagickaCost, "MagickaCost"); + getWidget(mSuccessChance, "SuccessChance"); + getWidget(mAvailableEffectsList, "AvailableEffects"); + getWidget(mUsedEffectsView, "UsedEffects"); + getWidget(mPriceLabel, "PriceLabel"); + getWidget(mBuyButton, "BuyButton"); + getWidget(mCancelButton, "CancelButton"); + + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked); + mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); + } + + + void SpellCreationDialog::open() + { + center(); + } + + void SpellCreationDialog::onReferenceUnavailable () + { + mWindowManager.removeGuiMode (GM_Dialogue); + mWindowManager.removeGuiMode (GM_SpellCreation); + } + + void SpellCreationDialog::startSpellMaking (MWWorld::Ptr actor) + { + mPtr = actor; + + // get the list of magic effects that are known to the player + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); + MWMechanics::Spells& spells = stats.getSpells(); + + std::vector<short> knownEffects; + + for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) + { + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + + // only normal spells count + if (spell->data.type != ESM::Spell::ST_Spell) + continue; + + const std::vector<ESM::ENAMstruct>& list = spell->effects.list; + for (std::vector<ESM::ENAMstruct>::const_iterator it2 = list.begin(); it2 != list.end(); ++it2) + { + if (std::find(knownEffects.begin(), knownEffects.end(), it2->effectID) == knownEffects.end()) + knownEffects.push_back(it2->effectID); + } + } + + std::sort(knownEffects.begin(), knownEffects.end(), sortMagicEffects); + + mAvailableEffectsList->clear (); + + for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) + { + mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( + MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString()); + } + mAvailableEffectsList->adjustSize (); + + for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) + { + std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( + MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString(); + MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); + + ToolTips::createMagicEffectToolTip (w, *it); + } + + } + + void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender) + { + mWindowManager.removeGuiMode (MWGui::GM_SpellCreation); + } + + void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender) + { + + } + +} diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp new file mode 100644 index 0000000000..d0919ced0a --- /dev/null +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -0,0 +1,40 @@ +#ifndef MWGUI_SPELLCREATION_H +#define MWGUI_SPELLCREATION_H + +#include "window_base.hpp" +#include "referenceinterface.hpp" +#include "list.hpp" + +namespace MWGui +{ + + class SpellCreationDialog : public WindowBase, public ReferenceInterface + { + public: + SpellCreationDialog(MWBase::WindowManager& parWindowManager); + + virtual void open(); + + void startSpellMaking(MWWorld::Ptr actor); + + protected: + virtual void onReferenceUnavailable (); + + void onCancelButtonClicked (MyGUI::Widget* sender); + void onBuyButtonClicked (MyGUI::Widget* sender); + + + MyGUI::EditBox* mNameEdit; + MyGUI::TextBox* mMagickaCost; + MyGUI::TextBox* mSuccessChance; + Widgets::MWList* mAvailableEffectsList; + MyGUI::ScrollView* mUsedEffectsView; + MyGUI::Button* mBuyButton; + MyGUI::Button* mCancelButton; + MyGUI::TextBox* mPriceLabel; + + }; + +} + +#endif diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 8186279d18..9beca795ef 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -586,8 +586,6 @@ void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId) widget->setUserString("Caption_SkillNoProgressDescription", skill->description); widget->setUserString("Caption_SkillNoProgressAttribute", "#{sGoverningAttribute}: #{" + attr->name + "}"); widget->setUserString("ImageTexture_SkillNoProgressImage", icon); - widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip"); - widget->setUserString("ToolTipLayout", "SkillNoProgressToolTip"); } void ToolTips::createAttributeToolTip(MyGUI::Widget* widget, int attributeId) @@ -713,6 +711,38 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe widget->setUserString("ToolTipLayout", "ClassToolTip"); } +void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) +{ + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld ()->getStore ().magicEffects.find(id); + const std::string &name = Widgets::MWSpellEffect::effectIDToString (id); + + std::string icon = effect->icon; + + int slashPos = icon.find("\\"); + icon.insert(slashPos+1, "b_"); + + icon[icon.size()-3] = 'd'; + icon[icon.size()-2] = 'd'; + icon[icon.size()-1] = 's'; + + icon = "icons\\" + icon; + + std::vector<std::string> schools; + schools.push_back ("#{sSchoolAlteration}"); + schools.push_back ("#{sSchoolConjuration}"); + schools.push_back ("#{sSchoolDestruction}"); + schools.push_back ("#{sSchoolIllusion}"); + schools.push_back ("#{sSchoolMysticism}"); + schools.push_back ("#{sSchoolRestoration}"); + + widget->setUserString("ToolTipType", "Layout"); + widget->setUserString("ToolTipLayout", "MagicEffectToolTip"); + widget->setUserString("Caption_MagicEffectName", "#{" + name + "}"); + widget->setUserString("Caption_MagicEffectDescription", effect->description); + widget->setUserString("Caption_MagicEffectSchool", "#{sSchool}: " + schools[effect->data.school]); + widget->setUserString("ImageTexture_MagicEffectImage", icon); +} + void ToolTips::setDelay(float delay) { mDelay = delay; diff --git a/apps/openmw/mwgui/tooltips.hpp b/apps/openmw/mwgui/tooltips.hpp index f67b6ea5c1..270df4ae2f 100644 --- a/apps/openmw/mwgui/tooltips.hpp +++ b/apps/openmw/mwgui/tooltips.hpp @@ -71,6 +71,7 @@ namespace MWGui static void createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId); static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace); static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass); + static void createMagicEffectToolTip(MyGUI::Widget* widget, short id); private: MyGUI::Widget* mDynamicToolTipBox; diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 6298ea77d7..899ceadd9c 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -249,7 +249,7 @@ namespace MWGui void setWindowManager(MWBase::WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setSpellEffect(const SpellEffectParams& params); - std::string effectIDToString(const short effectID); + static std::string effectIDToString(const short effectID); bool effectHasMagnitude (const std::string& effect); bool effectHasDuration (const std::string& effect); bool effectInvolvesAttribute (const std::string& effect); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index e6f9e8565b..890b3bc138 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -46,6 +46,7 @@ #include "loadingscreen.hpp" #include "levelupdialog.hpp" #include "waitdialog.hpp" +#include "spellcreationdialog.hpp" using namespace MWGui; @@ -75,6 +76,7 @@ WindowManager::WindowManager( , mCharGen(NULL) , mLevelupDialog(NULL) , mWaitDialog(NULL) + , mSpellCreationDialog(NULL) , mPlayerClass() , mPlayerName() , mPlayerRaceId() @@ -155,6 +157,7 @@ WindowManager::WindowManager( mQuickKeysMenu = new QuickKeysMenu(*this); mLevelupDialog = new LevelupDialog(*this); mWaitDialog = new WaitDialog(*this); + mSpellCreationDialog = new SpellCreationDialog(*this); mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this); mLoadingScreen->onResChange (w,h); @@ -210,6 +213,7 @@ WindowManager::~WindowManager() delete mLoadingScreen; delete mLevelupDialog; delete mWaitDialog; + delete mSpellCreationDialog; cleanupGarbage(); @@ -259,6 +263,7 @@ void WindowManager::updateVisible() mQuickKeysMenu->setVisible(false); mLevelupDialog->setVisible(false); mWaitDialog->setVisible(false); + mSpellCreationDialog->setVisible(false); mHud->setVisible(true); @@ -359,6 +364,9 @@ void WindowManager::updateVisible() case GM_SpellBuying: mSpellBuyingWindow->setVisible(true); break; + case GM_SpellCreation: + mSpellCreationDialog->setVisible(true); + break; case GM_InterMessageBox: break; case GM_Journal: @@ -561,6 +569,7 @@ void WindowManager::onFrame (float frameDuration) mDialogueWindow->checkReferenceAvailable(); mTradeWindow->checkReferenceAvailable(); mSpellBuyingWindow->checkReferenceAvailable(); + mSpellCreationDialog->checkReferenceAvailable(); mContainerWindow->checkReferenceAvailable(); mConsole->checkReferenceAvailable(); } @@ -960,3 +969,8 @@ void WindowManager::addVisitedLocation(const std::string& name, int x, int y) { mMap->addVisitedLocation (name, x, y); } + +void WindowManager::startSpellMaking(MWWorld::Ptr actor) +{ + mSpellCreationDialog->startSpellMaking (actor); +} diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index d7773e2619..ec9fe8fae8 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -64,6 +64,8 @@ namespace MWGui class LoadingScreen; class LevelupDialog; class WaitDialog; + class SpellCreationDialog; + class WindowManager : public MWBase::WindowManager { @@ -210,6 +212,8 @@ namespace MWGui virtual bool getPlayerSleeping(); + virtual void startSpellMaking(MWWorld::Ptr actor); + private: OEngine::GUI::MyGUIManager *mGuiManager; HUD *mHud; @@ -237,6 +241,7 @@ namespace MWGui LoadingScreen* mLoadingScreen; LevelupDialog* mLevelupDialog; WaitDialog* mWaitDialog; + SpellCreationDialog* mSpellCreationDialog; CharacterCreation* mCharGen; diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index ae8d3afbed..2a1bf75109 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -75,6 +75,7 @@ set(MYGUI_FILES openmw_levelup_dialog.layout openmw_wait_dialog.layout openmw_wait_dialog_progressbar.layout + openmw_spellcreation_dialog.layout smallbars.png VeraMono.ttf markers.png diff --git a/files/mygui/openmw_spellcreation_dialog.layout b/files/mygui/openmw_spellcreation_dialog.layout new file mode 100644 index 0000000000..2013fece8c --- /dev/null +++ b/files/mygui/openmw_spellcreation_dialog.layout @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<MyGUI type="Layout"> + <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 560 400" name="_Main"> + + <Widget type="HBox" position="12 12 250 30"> + + <Widget type="AutoSizedTextBox" skin="NormalText"> + <Property key="Caption" value="#{sName}"/> + </Widget> + + <Widget type="EditBox" skin="MW_TextEdit" position="0 0 30 30" name="NameEdit"> + <UserString key="HStretch" value="true"/> + </Widget> + + <Widget type="Widget"> + </Widget> + + </Widget> + + <Widget type="TextBox" skin="NormalText" position="280 0 300 24"> + <Property key="Caption" value="#{sEnchantmentMenu4}"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="280 0 258 24" name="MagickaCost"> + <Property key="Caption" value="1"/> + <Property key="TextAlign" value="Right HCenter"/> + </Widget> + + + <Widget type="TextBox" skin="NormalText" position="280 24 300 24"> + <Property key="Caption" value="#{sSpellmakingMenu1}"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="280 24 258 24" name="SuccessChance"> + <Property key="Caption" value="39"/> + <Property key="TextAlign" value="Right HCenter"/> + </Widget> + + + <!-- Available effects --> + <Widget type="TextBox" skin="NormalText" position="12 48 300 24"> + <Property key="Caption" value="#{sMagicEffects}"/> + </Widget> + <Widget type="MWList" skin="MW_SimpleList" position="12 76 202 269" name="AvailableEffects"> + </Widget> + + <!-- Used effects --> + <Widget type="TextBox" skin="NormalText" position="226 48 300 24"> + <Property key="Caption" value="#{sEffects}"/> + </Widget> + <Widget type="Widget" skin="MW_Box" position="226 76 316 269"> + <Widget type="ScrollView" skin="MW_ScrollView" position="4 4 308 261" name="UsedEffects"> + </Widget> + </Widget> + + <Widget type="HBox" position="0 340 560 60"> + <Property key="Padding" value="16"/> + + <Widget type="Widget" position="0 0 0 0"> + <UserString key="HStretch" value="true"/> + </Widget> + + <Widget type="AutoSizedTextBox" skin="NormalText"> + <Property key="Caption" value="#{sBarterDialog7}"/> + </Widget> + <Widget type="AutoSizedTextBox" skin="SandText" name="PriceLabel"> + <Property key="Caption" value="30"/> + </Widget> + + + <Widget type="AutoSizedButton" skin="MW_Button" name="BuyButton"> + <Property key="Caption" value="#{sBuy}"/> + </Widget> + + <Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton"> + <Property key="Caption" value="#{sCancel}"/> + </Widget> + </Widget> + + </Widget> +</MyGUI> diff --git a/files/mygui/openmw_tooltips.layout b/files/mygui/openmw_tooltips.layout index 148e98064f..514d1a25b3 100644 --- a/files/mygui/openmw_tooltips.layout +++ b/files/mygui/openmw_tooltips.layout @@ -196,6 +196,31 @@ </Widget> </Widget> + <!-- Magic effect tooltip --> + <Widget type="Widget" skin="HUD_Box_NoTransp" position="0 0 300 52" align="Stretch" name="MagicEffectToolTip"> + <Property key="Visible" value="false"/> + + <Widget type="ImageBox" skin="ImageBox" position="8 8 32 32" align="Left Top" name="MagicEffectImage"/> + + <Widget type="TextBox" skin="NormalText" position="44 8 252 16" align="Left Top HStretch" name="MagicEffectName"> + <Property key="TextAlign" value="Left"/> + <UserString key="AutoResizeHorizontal" value="true"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="44 24 252 16" align="Left Top HStretch" name="MagicEffectSchool"> + <Property key="TextAlign" value="Left"/> + <UserString key="AutoResizeHorizontal" value="true"/> + </Widget> + + <Widget type="EditBox" skin="SandText" position="8 44 284 0" align="Left Top Stretch" name="MagicEffectDescription"> + <Property key="MultiLine" value="true"/> + <Property key="WordWrap" value="true"/> + <Property key="TextAlign" value="Left Top"/> + <UserString key="AutoResizeHorizontal" value="true"/> + <UserString key="AutoResizeVertical" value="true"/> + </Widget> + </Widget> + </Widget> </MyGUI> From d393f551ed4b3e4bc242676da87cebf63fcbbb71 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Mon, 24 Sep 2012 08:09:16 +0200 Subject: [PATCH 002/255] edit effect dialog --- apps/openmw/mwgui/list.cpp | 1 + apps/openmw/mwgui/list.hpp | 8 ++ apps/openmw/mwgui/spellcreationdialog.cpp | 92 +++++++++++++++++++++++ apps/openmw/mwgui/spellcreationdialog.hpp | 44 +++++++++++ files/mygui/CMakeLists.txt | 1 + files/mygui/openmw_edit_effect.layout | 88 ++++++++++++++++++++++ 6 files changed, 234 insertions(+) create mode 100644 files/mygui/openmw_edit_effect.layout diff --git a/apps/openmw/mwgui/list.cpp b/apps/openmw/mwgui/list.cpp index ff23f8b311..0bafced97b 100644 --- a/apps/openmw/mwgui/list.cpp +++ b/apps/openmw/mwgui/list.cpp @@ -128,6 +128,7 @@ void MWList::onItemSelected(MyGUI::Widget* _sender) std::string name = static_cast<MyGUI::Button*>(_sender)->getCaption(); eventItemSelected(name); + eventWidgetSelected(_sender); } MyGUI::Widget* MWList::getItemWidget(const std::string& name) diff --git a/apps/openmw/mwgui/list.hpp b/apps/openmw/mwgui/list.hpp index c1f2d83b56..d07d49de63 100644 --- a/apps/openmw/mwgui/list.hpp +++ b/apps/openmw/mwgui/list.hpp @@ -18,6 +18,7 @@ namespace MWGui MWList(); typedef MyGUI::delegates::CMultiDelegate1<std::string> EventHandle_String; + typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget; /** * Event: Item selected with the mouse. @@ -25,6 +26,13 @@ namespace MWGui */ EventHandle_String eventItemSelected; + /** + * Event: Item selected with the mouse. + * signature: void method(MyGUI::Widget* sender) + */ + EventHandle_Widget eventWidgetSelected; + + /** * Call after the size of the list changed, or items were inserted/removed */ diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index fd5e9594c7..b1748edf8c 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -29,8 +29,86 @@ namespace namespace MWGui { + EditEffectDialog::EditEffectDialog(MWBase::WindowManager &parWindowManager) + : WindowModal("openmw_edit_effect.layout", parWindowManager) + , mRange(ESM::RT_Touch) + { + getWidget(mCancelButton, "CancelButton"); + getWidget(mOkButton, "OkButton"); + getWidget(mDeleteButton, "DeleteButton"); + getWidget(mRangeButton, "RangeButton"); + getWidget(mMagnitudeMinValue, "MagnitudeMinValue"); + getWidget(mMagnitudeMaxValue, "MagnitudeMaxValue"); + getWidget(mDurationValue, "DurationValue"); + getWidget(mAreaValue, "AreaValue"); + getWidget(mMagnitudeMinSlider, "MagnitudeMinSlider"); + getWidget(mMagnitudeMaxSlider, "MagnitudeMaxSlider"); + getWidget(mDurationSlider, "DurationSlider"); + getWidget(mAreaSlider, "AreaSlider"); + getWidget(mEffectImage, "EffectImage"); + getWidget(mEffectName, "EffectName"); + getWidget(mAreaText, "AreaText"); + + mRangeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onRangeButtonClicked); + mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onOkButtonClicked); + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onCancelButtonClicked); + mDeleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onDeleteButtonClicked); + } + + void EditEffectDialog::open() + { + WindowModal::open(); + center(); + } + + void EditEffectDialog::setEffect (const ESM::MagicEffect *effect) + { + std::string icon = effect->icon; + icon[icon.size()-3] = 'd'; + icon[icon.size()-2] = 'd'; + icon[icon.size()-1] = 's'; + icon = "icons\\" + icon; + + mEffectImage->setImageTexture (icon); + + mEffectName->setCaptionWithReplacing("#{"+Widgets::MWSpellEffect::effectIDToString (effect->index)+"}"); + } + + void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender) + { + mRange = (mRange+1)%3; + + if (mRange == ESM::RT_Self) + mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}"); + else if (mRange == ESM::RT_Target) + mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}"); + else if (mRange == ESM::RT_Touch) + mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}"); + + mAreaSlider->setVisible (mRange != ESM::RT_Self); + mAreaText->setVisible (mRange != ESM::RT_Self); + } + + void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender) + { + + } + + void EditEffectDialog::onOkButtonClicked (MyGUI::Widget* sender) + { + setVisible(false); + } + + void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender) + { + setVisible(false); + } + + // ------------------------------------------------------------------------------------------------ + SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) : WindowBase("openmw_spellcreation_dialog.layout", parWindowManager) + , mAddEffectDialog(parWindowManager) { getWidget(mNameEdit, "NameEdit"); getWidget(mMagickaCost, "MagickaCost"); @@ -41,8 +119,12 @@ namespace MWGui getWidget(mBuyButton, "BuyButton"); getWidget(mCancelButton, "CancelButton"); + mAddEffectDialog.setVisible(false); + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked); mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); + + mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onAvailableEffectClicked); } @@ -101,6 +183,7 @@ namespace MWGui std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString(); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); + w->setUserData(*it); ToolTips::createMagicEffectToolTip (w, *it); } @@ -117,4 +200,13 @@ namespace MWGui } + void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender) + { + mAddEffectDialog.setVisible(true); + + short effectId = *sender->getUserData<short>(); + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); + mAddEffectDialog.setEffect (effect); + } + } diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index d0919ced0a..8ea8ebb2dc 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -8,6 +8,47 @@ namespace MWGui { + class EditEffectDialog : public WindowModal + { + public: + EditEffectDialog(MWBase::WindowManager& parWindowManager); + + virtual void open(); + + void setEffect (const ESM::MagicEffect* effect); + + protected: + MyGUI::Button* mCancelButton; + MyGUI::Button* mOkButton; + MyGUI::Button* mDeleteButton; + + MyGUI::Button* mRangeButton; + + MyGUI::TextBox* mMagnitudeMinValue; + MyGUI::TextBox* mMagnitudeMaxValue; + MyGUI::TextBox* mDurationValue; + MyGUI::TextBox* mAreaValue; + + MyGUI::ScrollBar* mMagnitudeMinSlider; + MyGUI::ScrollBar* mMagnitudeMaxSlider; + MyGUI::ScrollBar* mDurationSlider; + MyGUI::ScrollBar* mAreaSlider; + + MyGUI::ScrollBar* mAreaText; + + MyGUI::ImageBox* mEffectImage; + MyGUI::TextBox* mEffectName; + + protected: + void onRangeButtonClicked (MyGUI::Widget* sender); + void onDeleteButtonClicked (MyGUI::Widget* sender); + void onOkButtonClicked (MyGUI::Widget* sender); + void onCancelButtonClicked (MyGUI::Widget* sender); + + protected: + int mRange; + }; + class SpellCreationDialog : public WindowBase, public ReferenceInterface { public: @@ -22,6 +63,7 @@ namespace MWGui void onCancelButtonClicked (MyGUI::Widget* sender); void onBuyButtonClicked (MyGUI::Widget* sender); + void onAvailableEffectClicked (MyGUI::Widget* sender); MyGUI::EditBox* mNameEdit; @@ -33,6 +75,8 @@ namespace MWGui MyGUI::Button* mCancelButton; MyGUI::TextBox* mPriceLabel; + EditEffectDialog mAddEffectDialog; + }; } diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index 2a1bf75109..d948a4cf7f 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -76,6 +76,7 @@ set(MYGUI_FILES openmw_wait_dialog.layout openmw_wait_dialog_progressbar.layout openmw_spellcreation_dialog.layout + openmw_edit_effect.layout smallbars.png VeraMono.ttf markers.png diff --git a/files/mygui/openmw_edit_effect.layout b/files/mygui/openmw_edit_effect.layout new file mode 100644 index 0000000000..884723febd --- /dev/null +++ b/files/mygui/openmw_edit_effect.layout @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<MyGUI type="Layout"> + <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 362 310" name="_Main"> + + <Widget type="ImageBox" skin="ImageBox" position="8 12 16 16" name="EffectImage"> + </Widget> + + <Widget type="TextBox" skin="NormalText" position="36 8 400 24" name="EffectName"> + <Property key="TextAlign" value="Left HCenter"/> + </Widget> + + + <!-- Range --> + <Widget type="TextBox" skin="NormalText" position="8 36 400 24"> + <Property key="Caption" value="#{sRange}"/> + <Property key="TextAlign" value="Left HCenter"/> + </Widget> + <Widget type="AutoSizedButton" skin="MW_Button" position="130 36 0 24" name="RangeButton"> + <Property key="Caption" value="#{sRangeTouch}"/> + </Widget> + + <!-- Magnitude --> + <Widget type="TextBox" skin="NormalText" position="8 80 400 24"> + <Property key="Caption" value="#{sMagnitude}"/> + <Property key="TextAlign" value="Left HCenter"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="130 80 210 20" name="MagnitudeMinValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="130 100 210 13" name="MagnitudeMinSlider"> + </Widget> + + <Widget type="TextBox" skin="SandText" position="130 112 210 20" name="MagnitudeMaxValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="130 132 210 13" name="MagnitudeMaxSlider"> + </Widget> + + <!-- Duration --> + <Widget type="TextBox" skin="NormalText" position="8 173 400 24"> + <Property key="Caption" value="#{sDuration}"/> + <Property key="TextAlign" value="Left Top"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="130 153 210 20" name="DurationValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="130 173 210 13" name="DurationSlider"> + </Widget> + + <!-- Area --> + <Widget type="TextBox" skin="NormalText" position="8 217 400 24" name="AreaText"> + <Property key="Caption" value="#{sArea}"/> + <Property key="TextAlign" value="Left Top"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="130 197 210 20" name="AreaValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="130 217 210 13" name="AreaSlider"> + </Widget> + + <Widget type="HBox" position="8 266 336 24"> + <Widget type="Widget"> + <UserString key="HStretch" value="true"/> + </Widget> + + <Widget type="AutoSizedButton" skin="MW_Button" name="DeleteButton"> + <Property key="Caption" value="#{sDelete}"/> + </Widget> + + <Widget type="AutoSizedButton" skin="MW_Button" name="OkButton"> + <Property key="Caption" value="#{sOk}"/> + </Widget> + + <Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton"> + <Property key="Caption" value="#{sCancel}"/> + </Widget> + </Widget> + + </Widget> +</MyGUI> From b63d205c6e5dcb8ff36377a91ad831913bdb6000 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Mon, 24 Sep 2012 22:09:38 +0200 Subject: [PATCH 003/255] change the select attribute/skill dialogs to be reusable --- apps/openmw/mwgui/class.cpp | 18 ++++++++---------- apps/openmw/mwgui/class.hpp | 10 +++------- apps/openmw/mwgui/spellcreationdialog.cpp | 23 +++++++++++++++-------- apps/openmw/mwgui/spellcreationdialog.hpp | 10 ++++++++-- apps/openmw/mwgui/widgets.hpp | 10 ++++++---- 5 files changed, 40 insertions(+), 31 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 309aa5a5d6..06fa325b62 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -565,7 +565,7 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) { delete mAttribDialog; mAttribDialog = new SelectAttributeDialog(mWindowManager); - mAttribDialog->setAffectedWidget(_sender); + mAffectedAttribute = _sender; mAttribDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); mAttribDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onAttributeSelected); mAttribDialog->setVisible(true); @@ -574,18 +574,17 @@ void CreateClassDialog::onAttributeClicked(Widgets::MWAttributePtr _sender) void CreateClassDialog::onAttributeSelected() { ESM::Attribute::AttributeID id = mAttribDialog->getAttributeId(); - Widgets::MWAttributePtr attribute = mAttribDialog->getAffectedWidget(); - if (attribute == mFavoriteAttribute0) + if (mAffectedAttribute == mFavoriteAttribute0) { if (mFavoriteAttribute1->getAttributeId() == id) mFavoriteAttribute1->setAttributeId(mFavoriteAttribute0->getAttributeId()); } - else if (attribute == mFavoriteAttribute1) + else if (mAffectedAttribute == mFavoriteAttribute1) { if (mFavoriteAttribute0->getAttributeId() == id) mFavoriteAttribute0->setAttributeId(mFavoriteAttribute1->getAttributeId()); } - attribute->setAttributeId(id); + mAffectedAttribute->setAttributeId(id); mWindowManager.removeDialog(mAttribDialog); mAttribDialog = 0; @@ -596,7 +595,7 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender) { delete mSkillDialog; mSkillDialog = new SelectSkillDialog(mWindowManager); - mSkillDialog->setAffectedWidget(_sender); + mAffectedSkill = _sender; mSkillDialog->eventCancel += MyGUI::newDelegate(this, &CreateClassDialog::onDialogCancel); mSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &CreateClassDialog::onSkillSelected); mSkillDialog->setVisible(true); @@ -605,22 +604,21 @@ void CreateClassDialog::onSkillClicked(Widgets::MWSkillPtr _sender) void CreateClassDialog::onSkillSelected() { ESM::Skill::SkillEnum id = mSkillDialog->getSkillId(); - Widgets::MWSkillPtr skill = mSkillDialog->getAffectedWidget(); // Avoid duplicate skills by swapping any skill field that matches the selected one std::vector<Widgets::MWSkillPtr>::const_iterator end = mSkills.end(); for (std::vector<Widgets::MWSkillPtr>::const_iterator it = mSkills.begin(); it != end; ++it) { - if (*it == skill) + if (*it == mAffectedSkill) continue; if ((*it)->getSkillId() == id) { - (*it)->setSkillId(skill->getSkillId()); + (*it)->setSkillId(mAffectedSkill->getSkillId()); break; } } - skill->setSkillId(mSkillDialog->getSkillId()); + mAffectedSkill->setSkillId(mSkillDialog->getSkillId()); mWindowManager.removeDialog(mSkillDialog); mSkillDialog = 0; update(); diff --git a/apps/openmw/mwgui/class.hpp b/apps/openmw/mwgui/class.hpp index 94e8558d03..c7699b3083 100644 --- a/apps/openmw/mwgui/class.hpp +++ b/apps/openmw/mwgui/class.hpp @@ -167,8 +167,6 @@ namespace MWGui ~SelectAttributeDialog(); ESM::Attribute::AttributeID getAttributeId() const { return mAttributeId; } - Widgets::MWAttributePtr getAffectedWidget() const { return mAffectedWidget; } - void setAffectedWidget(Widgets::MWAttributePtr widget) { mAffectedWidget = widget; } // Events typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; @@ -188,8 +186,6 @@ namespace MWGui void onCancelClicked(MyGUI::Widget* _sender); private: - Widgets::MWAttributePtr mAffectedWidget; - ESM::Attribute::AttributeID mAttributeId; }; @@ -200,8 +196,6 @@ namespace MWGui ~SelectSkillDialog(); ESM::Skill::SkillEnum getSkillId() const { return mSkillId; } - Widgets::MWSkillPtr getAffectedWidget() const { return mAffectedWidget; } - void setAffectedWidget(Widgets::MWSkillPtr widget) { mAffectedWidget = widget; } // Events typedef MyGUI::delegates::CMultiDelegate0 EventHandle_Void; @@ -224,7 +218,6 @@ namespace MWGui Widgets::MWSkillPtr mCombatSkill[9]; Widgets::MWSkillPtr mMagicSkill[9]; Widgets::MWSkillPtr mStealthSkill[9]; - Widgets::MWSkillPtr mAffectedWidget; ESM::Skill::SkillEnum mSkillId; }; @@ -301,6 +294,9 @@ namespace MWGui DescriptionDialog *mDescDialog; ESM::Class::Specialization mSpecializationId; + + Widgets::MWAttributePtr mAffectedAttribute; + Widgets::MWSkillPtr mAffectedSkill; }; } #endif diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index b1748edf8c..637e99d34b 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -31,7 +31,6 @@ namespace MWGui EditEffectDialog::EditEffectDialog(MWBase::WindowManager &parWindowManager) : WindowModal("openmw_edit_effect.layout", parWindowManager) - , mRange(ESM::RT_Touch) { getWidget(mCancelButton, "CancelButton"); getWidget(mOkButton, "OkButton"); @@ -59,6 +58,10 @@ namespace MWGui { WindowModal::open(); center(); + + mEffect.range = ESM::RT_Self; + + onRangeButtonClicked(mRangeButton); } void EditEffectDialog::setEffect (const ESM::MagicEffect *effect) @@ -76,17 +79,17 @@ namespace MWGui void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender) { - mRange = (mRange+1)%3; + mEffect.range = (mEffect.range+1)%3; - if (mRange == ESM::RT_Self) + if (mEffect.range == ESM::RT_Self) mRangeButton->setCaptionWithReplacing ("#{sRangeSelf}"); - else if (mRange == ESM::RT_Target) + else if (mEffect.range == ESM::RT_Target) mRangeButton->setCaptionWithReplacing ("#{sRangeTarget}"); - else if (mRange == ESM::RT_Touch) + else if (mEffect.range == ESM::RT_Touch) mRangeButton->setCaptionWithReplacing ("#{sRangeTouch}"); - mAreaSlider->setVisible (mRange != ESM::RT_Self); - mAreaText->setVisible (mRange != ESM::RT_Self); + mAreaSlider->setVisible (mEffect.range != ESM::RT_Self); + mAreaText->setVisible (mEffect.range != ESM::RT_Self); } void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender) @@ -109,6 +112,8 @@ namespace MWGui SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) : WindowBase("openmw_spellcreation_dialog.layout", parWindowManager) , mAddEffectDialog(parWindowManager) + , mSelectAttributeDialog(NULL) + , mSelectSkillDialog(NULL) { getWidget(mNameEdit, "NameEdit"); getWidget(mMagickaCost, "MagickaCost"); @@ -202,10 +207,12 @@ namespace MWGui void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender) { - mAddEffectDialog.setVisible(true); short effectId = *sender->getUserData<short>(); const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); + + + mAddEffectDialog.setVisible(true); mAddEffectDialog.setEffect (effect); } diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index 8ea8ebb2dc..a2db719a70 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -8,6 +8,9 @@ namespace MWGui { + class SelectSkillDialog; + class SelectAttributeDialog; + class EditEffectDialog : public WindowModal { public: @@ -34,7 +37,7 @@ namespace MWGui MyGUI::ScrollBar* mDurationSlider; MyGUI::ScrollBar* mAreaSlider; - MyGUI::ScrollBar* mAreaText; + MyGUI::TextBox* mAreaText; MyGUI::ImageBox* mEffectImage; MyGUI::TextBox* mEffectName; @@ -46,7 +49,7 @@ namespace MWGui void onCancelButtonClicked (MyGUI::Widget* sender); protected: - int mRange; + ESM::ENAMstruct mEffect; }; class SpellCreationDialog : public WindowBase, public ReferenceInterface @@ -77,6 +80,9 @@ namespace MWGui EditEffectDialog mAddEffectDialog; + SelectAttributeDialog* mSelectAttributeDialog; + SelectSkillDialog* mSelectSkillDialog; + }; } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 899ceadd9c..cc733122cd 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -250,10 +250,12 @@ namespace MWGui void setSpellEffect(const SpellEffectParams& params); static std::string effectIDToString(const short effectID); - bool effectHasMagnitude (const std::string& effect); - bool effectHasDuration (const std::string& effect); - bool effectInvolvesAttribute (const std::string& effect); - bool effectInvolvesSkill (const std::string& effect); + + /// \todo Remove all of these! The information can be obtained via the ESM::MagicEffect's flags! + static bool effectHasMagnitude (const std::string& effect); + static bool effectHasDuration (const std::string& effect); + static bool effectInvolvesAttribute (const std::string& effect); + static bool effectInvolvesSkill (const std::string& effect); int getRequestedWidth() const { return mRequestedWidth; } From 3060fbee603cc8b4dcaff65a00b70b9da722a200 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Wed, 26 Sep 2012 18:30:47 +0200 Subject: [PATCH 004/255] TravelGUI, not completly finished. --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwbase/windowmanager.hpp | 2 + apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 4 + apps/openmw/mwgui/dialogue.cpp | 14 +- apps/openmw/mwgui/dialogue.hpp | 2 + apps/openmw/mwgui/mode.hpp | 1 + apps/openmw/mwgui/travelwindow.cpp | 159 ++++++++++++++++++ apps/openmw/mwgui/travelwindow.hpp | 57 +++++++ apps/openmw/mwgui/windowmanagerimp.cpp | 9 + apps/openmw/mwgui/windowmanagerimp.hpp | 2 + 10 files changed, 249 insertions(+), 3 deletions(-) create mode 100644 apps/openmw/mwgui/travelwindow.cpp create mode 100644 apps/openmw/mwgui/travelwindow.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 66844b2806..e140f0db2e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -29,7 +29,7 @@ add_openmw_dir (mwgui map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list formatting inventorywindow container hud countdialog tradewindow settingswindow confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu - itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog + itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog travelwindow ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 4291631363..e6b9c64556 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -42,6 +42,7 @@ namespace MWGui class Console; class SpellWindow; class TradeWindow; + class TravelWindow; class SpellBuyingWindow; class ConfirmationDialog; class CountDialog; @@ -108,6 +109,7 @@ namespace MWBase virtual MWGui::ConfirmationDialog* getConfirmationDialog() = 0; virtual MWGui::TradeWindow* getTradeWindow() = 0; virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow() = 0; + virtual MWGui::TravelWindow* getTravelWindow() = 0; virtual MWGui::SpellWindow* getSpellWindow() = 0; virtual MWGui::Console* getConsole() = 0; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 1b7532d0a1..34d4a7981d 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -798,6 +798,10 @@ namespace MWDialogue win->setShowSpells(true); else win->setShowSpells(false); + if( !mActor.get<ESM::NPC>()->base->mTransport.empty()) + win->setShowTravel(true); + else + win->setShowTravel(false); // sort again, because the previous sort was case-sensitive keywordList.sort(stringCompareNoCase); diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 245487a049..860da51252 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -19,6 +19,7 @@ #include "tradewindow.hpp" #include "spellbuyingwindow.hpp" #include "inventorywindow.hpp" +#include "travelwindow.hpp" using namespace MWGui; using namespace Widgets; @@ -134,7 +135,13 @@ void DialogueWindow::onSelectTopic(std::string topic) mWindowManager.pushGuiMode(GM_SpellBuying); mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); } - + else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()) + { + std::cout << "travel!"; + mWindowManager.pushGuiMode(GM_Travel); + mWindowManager.getTravelWindow()->startTravel(mPtr); + //mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); + } else MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); } @@ -163,7 +170,10 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords) if (mShowSpells) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()); - if (anyService) + if(mShowTravel) + mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()); + + if (anyService || mShowTravel) mTopicsList->addSeparator(); for(std::list<std::string>::iterator it = keyWords.begin(); it != keyWords.end(); ++it) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index a43b0d5a70..caa5c7dc47 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -52,6 +52,7 @@ namespace MWGui // make sure to call these before setKeywords() void setShowTrade(bool show) { mShowTrade = show; } void setShowSpells(bool show) { mShowSpells = show; } + void setShowTravel(bool show) { mShowTravel = show; } protected: void onSelectTopic(std::string topic); @@ -72,6 +73,7 @@ namespace MWGui // various service button visibilities, depending if the npc/creature talked to has these services bool mShowTrade; bool mShowSpells; + bool mShowTravel; bool mEnabled; diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index 64aa1dc216..4dd642f6d1 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -22,6 +22,7 @@ namespace MWGui GM_Rest, GM_RestBed, GM_SpellBuying, + GM_Travel, GM_Levelup, diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp new file mode 100644 index 0000000000..91966e19b6 --- /dev/null +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -0,0 +1,159 @@ +#include "travelwindow.hpp" + +#include <algorithm> + +#include <boost/lexical_cast.hpp> + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" +#include "../mwbase/soundmanager.hpp" +#include "../mwbase/windowmanager.hpp" + +#include "../mwworld/player.hpp" +#include "../mwworld/manualref.hpp" + +#include "../mwmechanics/spells.hpp" +#include "../mwmechanics/creaturestats.hpp" + +#include "inventorywindow.hpp" +#include "tradewindow.hpp" + +namespace MWGui +{ + const int TravelWindow::sLineHeight = 18; + + TravelWindow::TravelWindow(MWBase::WindowManager& parWindowManager) : + WindowBase("openmw_spell_buying_window.layout", parWindowManager) + , ContainerBase(NULL) // no drag&drop + , mCurrentY(0) + , mLastPos(0) + { + setCoord(0, 0, 450, 300); + + getWidget(mCancelButton, "CancelButton"); + getWidget(mPlayerGold, "PlayerGold"); + getWidget(mSelect, "Select"); + getWidget(mDestinations, "Spells"); + getWidget(mDestinationsView, "SpellsView"); + + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onCancelButtonClicked); + + mDestinations->setCoord(450/2-mDestinations->getTextSize().width/2, + mDestinations->getTop(), + mDestinations->getTextSize().width, + mDestinations->getHeight()); + mSelect->setCoord(8, + mSelect->getTop(), + mSelect->getTextSize().width, + mSelect->getHeight()); + } + + void TravelWindow::addDestination(const std::string& travelId) + { + //std::cout << "travel to" << travelId; + /*const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + int price = spell->data.cost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat();*/ + int price = 0; + MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); + mCurrentY += sLineHeight; + /// \todo price adjustment depending on merchantile skill + toAdd->setUserData(price); + toAdd->setCaptionWithReplacing(travelId+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); + toAdd->setSize(toAdd->getTextSize().width,sLineHeight); + toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); + toAdd->setUserString("ToolTipType", "Spell"); + toAdd->setUserString("Spell", travelId); + toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick); + mDestinationsWidgetMap.insert(std::make_pair (toAdd, travelId)); + } + + void TravelWindow::clearDestinations() + { + mDestinationsView->setViewOffset(MyGUI::IntPoint(0,0)); + mCurrentY = 0; + while (mDestinationsView->getChildCount()) + MyGUI::Gui::getInstance().destroyWidget(mDestinationsView->getChildAt(0)); + mDestinationsWidgetMap.clear(); + } + + void TravelWindow::startTravel(const MWWorld::Ptr& actor) + { + center(); + mActor = actor; + clearDestinations(); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + /*MWMechanics::Spells& playerSpells = MWWorld::Class::get (player).getCreatureStats (player).getSpells(); + MWMechanics::Spells& merchantSpells = MWWorld::Class::get (actor).getCreatureStats (actor).getSpells(); + + for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) + { + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); + + if (spell->data.type!=ESM::Spell::ST_Spell) + continue; // don't try to sell diseases, curses or powers + + if (std::find (playerSpells.begin(), playerSpells.end(), *iter)!=playerSpells.end()) + continue; // we have that spell already + + addDestination (*iter); + }*/ + + for(int i = 0;i<mActor.get<ESM::NPC>()->base->mTransport.size();i++) + { + addDestination(mActor.get<ESM::NPC>()->base->mTransport[i].mCellName); + } + + updateLabels(); + + mDestinationsView->setCanvasSize (MyGUI::IntSize(mDestinationsView->getWidth(), std::max(mDestinationsView->getHeight(), mCurrentY))); + } + + void TravelWindow::onTravelButtonClick(MyGUI::Widget* _sender) + { + /*int price = *_sender->getUserData<int>(); + + if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) + { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); + MWMechanics::Spells& spells = stats.getSpells(); + spells.add (mSpellsWidgetMap.find(_sender)->second); + mWindowManager.getTradeWindow()->addOrRemoveGold(-price); + startSpellBuying(mActor); + + MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); + }*/ + } + + void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender) + { + mWindowManager.removeGuiMode(GM_Travel); + } + + void TravelWindow::updateLabels() + { + mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold())); + mPlayerGold->setCoord(8, + mPlayerGold->getTop(), + mPlayerGold->getTextSize().width, + mPlayerGold->getHeight()); + } + + void TravelWindow::onReferenceUnavailable() + { + // remove both Spells and Dialogue (since you always trade with the NPC/creature that you have previously talked to) + mWindowManager.removeGuiMode(GM_Travel); + mWindowManager.removeGuiMode(GM_Dialogue); + } + + void TravelWindow::onMouseWheel(MyGUI::Widget* _sender, int _rel) + { + if (mDestinationsView->getViewOffset().top + _rel*0.3 > 0) + mDestinationsView->setViewOffset(MyGUI::IntPoint(0, 0)); + else + mDestinationsView->setViewOffset(MyGUI::IntPoint(0, mDestinationsView->getViewOffset().top + _rel*0.3)); + } +} + diff --git a/apps/openmw/mwgui/travelwindow.hpp b/apps/openmw/mwgui/travelwindow.hpp new file mode 100644 index 0000000000..07a516ce80 --- /dev/null +++ b/apps/openmw/mwgui/travelwindow.hpp @@ -0,0 +1,57 @@ +#ifndef MWGUI_TravelWINDOW_H +#define MWGUI_TravelWINDOW_H + +#include "container.hpp" +#include "window_base.hpp" + +#include "../mwworld/ptr.hpp" + +namespace MyGUI +{ + class Gui; + class Widget; +} + +namespace MWGui +{ + class WindowManager; +} + + +namespace MWGui +{ + class TravelWindow : public ContainerBase, public WindowBase + { + public: + TravelWindow(MWBase::WindowManager& parWindowManager); + + void startTravel(const MWWorld::Ptr& actor); + + protected: + MyGUI::Button* mCancelButton; + MyGUI::TextBox* mPlayerGold; + MyGUI::TextBox* mDestinations; + MyGUI::TextBox* mSelect; + + MyGUI::ScrollView* mDestinationsView; + + MWWorld::Ptr mActor; + + std::map<MyGUI::Widget*, std::string> mDestinationsWidgetMap; + + void onCancelButtonClicked(MyGUI::Widget* _sender); + void onTravelButtonClick(MyGUI::Widget* _sender); + void onMouseWheel(MyGUI::Widget* _sender, int _rel); + void addDestination(const std::string& destinationID); + void clearDestinations(); + int mLastPos,mCurrentY; + + static const int sLineHeight; + + void updateLabels(); + + virtual void onReferenceUnavailable(); + }; +} + +#endif diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 5a04a90c0f..811edcba0c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -38,6 +38,7 @@ #include "countdialog.hpp" #include "tradewindow.hpp" #include "spellbuyingwindow.hpp" +#include "travelwindow.hpp" #include "settingswindow.hpp" #include "confirmationdialog.hpp" #include "alchemywindow.hpp" @@ -67,6 +68,7 @@ WindowManager::WindowManager( , mCountDialog(NULL) , mTradeWindow(NULL) , mSpellBuyingWindow(NULL) + , mTravelWindow(NULL) , mSettingsWindow(NULL) , mConfirmationDialog(NULL) , mAlchemyWindow(NULL) @@ -141,6 +143,7 @@ WindowManager::WindowManager( mInventoryWindow = new InventoryWindow(*this,mDragAndDrop); mTradeWindow = new TradeWindow(*this); mSpellBuyingWindow = new SpellBuyingWindow(*this); + mTravelWindow = new TravelWindow(*this); mDialogueWindow = new DialogueWindow(*this); mContainerWindow = new ContainerWindow(*this,mDragAndDrop); mHud = new HUD(w,h, mShowFPSLevel, mDragAndDrop); @@ -203,6 +206,7 @@ WindowManager::~WindowManager() delete mScrollWindow; delete mTradeWindow; delete mSpellBuyingWindow; + delete mTravelWindow; delete mSettingsWindow; delete mConfirmationDialog; delete mAlchemyWindow; @@ -253,6 +257,7 @@ void WindowManager::updateVisible() mBookWindow->setVisible(false); mTradeWindow->setVisible(false); mSpellBuyingWindow->setVisible(false); + mTravelWindow->setVisible(false); mSettingsWindow->setVisible(false); mAlchemyWindow->setVisible(false); mSpellWindow->setVisible(false); @@ -359,6 +364,9 @@ void WindowManager::updateVisible() case GM_SpellBuying: mSpellBuyingWindow->setVisible(true); break; + case GM_Travel: + mTravelWindow->setVisible(true); + break; case GM_InterMessageBox: break; case GM_Journal: @@ -844,6 +852,7 @@ MWGui::CountDialog* WindowManager::getCountDialog() { return mCountDialog; } MWGui::ConfirmationDialog* WindowManager::getConfirmationDialog() { return mConfirmationDialog; } MWGui::TradeWindow* WindowManager::getTradeWindow() { return mTradeWindow; } MWGui::SpellBuyingWindow* WindowManager::getSpellBuyingWindow() { return mSpellBuyingWindow; } +MWGui::TravelWindow* WindowManager::getTravelWindow() { return mTravelWindow; } MWGui::SpellWindow* WindowManager::getSpellWindow() { return mSpellWindow; } MWGui::Console* WindowManager::getConsole() { return mConsole; } diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index d7773e2619..635a7483c8 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -111,6 +111,7 @@ namespace MWGui virtual MWGui::ConfirmationDialog* getConfirmationDialog(); virtual MWGui::TradeWindow* getTradeWindow(); virtual MWGui::SpellBuyingWindow* getSpellBuyingWindow(); + virtual MWGui::TravelWindow* getTravelWindow(); virtual MWGui::SpellWindow* getSpellWindow(); virtual MWGui::Console* getConsole(); @@ -229,6 +230,7 @@ namespace MWGui CountDialog* mCountDialog; TradeWindow* mTradeWindow; SpellBuyingWindow* mSpellBuyingWindow; + TravelWindow* mTravelWindow; SettingsWindow* mSettingsWindow; ConfirmationDialog* mConfirmationDialog; AlchemyWindow* mAlchemyWindow; From cd343c4fbd5a99d12126fdc99fa61c03e60e0409 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 27 Sep 2012 11:59:40 +0200 Subject: [PATCH 005/255] Issue #61: Basic alchemy class (doesn't do anything yet) --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwgui/alchemywindow.cpp | 4 +++- apps/openmw/mwgui/alchemywindow.hpp | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 66844b2806..69cfb2fd59 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -61,7 +61,7 @@ add_openmw_dir (mwclass add_openmw_dir (mwmechanics mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells - activespells npcstats aipackage aisequence + activespells npcstats aipackage aisequence alchemy ) add_openmw_dir (mwbase diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 3080298102..6fd88d5caa 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -253,8 +253,10 @@ namespace MWGui void AlchemyWindow::open() { - openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr setFilter(ContainerBase::Filter_Ingredients); + + mAlchemy.setAlchemist (mPtr); // pick the best available apparatus MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr); diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index 53e7178d50..67378d7de1 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -1,6 +1,8 @@ #ifndef MWGUI_ALCHEMY_H #define MWGUI_ALCHEMY_H +#include "../mwmechanics/alchemy.hpp" + #include "window_base.hpp" #include "container.hpp" #include "widgets.hpp" @@ -46,6 +48,10 @@ namespace MWGui virtual void onReferenceUnavailable() { ; } void update(); + + private: + + MWMechanics::Alchemy mAlchemy; }; } From 1971ba66f18cccd06b60b63b7b29c06e46ebf7de Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Thu, 27 Sep 2012 13:08:38 +0200 Subject: [PATCH 006/255] destination name is now OK for every trave services --- apps/openmw/mwgui/travelwindow.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 91966e19b6..9e7b0a9751 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -102,7 +102,12 @@ namespace MWGui for(int i = 0;i<mActor.get<ESM::NPC>()->base->mTransport.size();i++) { - addDestination(mActor.get<ESM::NPC>()->base->mTransport[i].mCellName); + std::string cellname = mActor.get<ESM::NPC>()->base->mTransport[i].mCellName; + int x,y; + MWBase::Environment::get().getWorld()->positionToIndex(mActor.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0], + mActor.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y); + if(cellname == "") cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->name; + addDestination(cellname); } updateLabels(); From 636f297f10fd41e5c083a0b02f2edda7ff3de22e Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 28 Sep 2012 16:52:42 +0200 Subject: [PATCH 007/255] enchant --- files/mygui/core_layouteditor.xml | 2 +- files/mygui/openmw_enchanting_dialog.layout | 88 +++++++++++++++++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/files/mygui/core_layouteditor.xml b/files/mygui/core_layouteditor.xml index 740f129cc6..db917b6efe 100644 --- a/files/mygui/core_layouteditor.xml +++ b/files/mygui/core_layouteditor.xml @@ -3,7 +3,7 @@ <MyGUI type="List"> <List file="core.skin" /> <List file="openmw_resources.xml" /> - <List file="openmw.font.xml" /> + <List file="openmw_font.xml"/> <List file="openmw_text.skin.xml" /> <List file="openmw_windows.skin.xml" /> <List file="openmw_button.skin.xml" /> diff --git a/files/mygui/openmw_enchanting_dialog.layout b/files/mygui/openmw_enchanting_dialog.layout index 1d622244a6..ea8156056e 100644 --- a/files/mygui/openmw_enchanting_dialog.layout +++ b/files/mygui/openmw_enchanting_dialog.layout @@ -3,6 +3,94 @@ <MyGUI type="Layout"> <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 560 400" name="_Main"> + <Widget type="HBox" position="12 12 250 30"> + + <Widget type="AutoSizedTextBox" skin="NormalText"> + <Property key="Caption" value="#{sName}"/> + </Widget> + + <Widget type="EditBox" skin="MW_TextEdit" position="0 0 30 30" name="NameEdit"> + <UserString key="HStretch" value="true"/> + </Widget> + + <Widget type="Widget"> + </Widget> + + </Widget> + + <!-- Item --> + <Widget type="AutoSizedTextBox" skin="NormalText" position="12 48 0 24"> + <Property key="Caption" value="#{sItem}"/> + </Widget> + + + + <Widget type="TextBox" skin="NormalText" position="280 0 300 24"> + <Property key="Caption" value="#{sEnchantmentMenu3}:"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="280 0 258 24" name="Enchantment"> + <Property key="Caption" value="1"/> + <Property key="TextAlign" value="Right HCenter"/> + </Widget> + + + <Widget type="TextBox" skin="NormalText" position="280 24 300 24"> + <Property key="Caption" value="#{sCastCost}:"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="280 24 258 24" name="CastCost"> + <Property key="Caption" value="39"/> + <Property key="TextAlign" value="Right HCenter"/> + </Widget> + + + <Widget type="TextBox" skin="NormalText" position="280 48 300 24"> + <Property key="Caption" value="#{sCharges}"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="280 48 258 24" name="Charge"> + <Property key="Caption" value="39"/> + <Property key="TextAlign" value="Right HCenter"/> + </Widget> + + + <!-- Available effects --> + <Widget type="TextBox" skin="NormalText" position="12 148 300 24"> + <Property key="Caption" value="#{sMagicEffects}"/> + </Widget> + <Widget type="MWList" skin="MW_SimpleList" position="12 176 202 169" name="AvailableEffects"> + </Widget> + + <!-- Used effects --> + <Widget type="TextBox" skin="NormalText" position="226 148 300 24"> + <Property key="Caption" value="#{sEffects}"/> + </Widget> + <Widget type="Widget" skin="MW_Box" position="226 176 316 169"> + <Widget type="ScrollView" skin="MW_ScrollView" position="4 4 308 161" name="UsedEffects"> + </Widget> + </Widget> + + <Widget type="HBox" position="0 340 560 60"> + <Property key="Padding" value="16"/> + + <Widget type="Widget" position="0 0 0 0"> + <UserString key="HStretch" value="true"/> + </Widget> + + <Widget type="AutoSizedTextBox" skin="NormalText"> + <Property key="Caption" value="#{sBarterDialog7}"/> + </Widget> + <Widget type="AutoSizedTextBox" skin="SandText" name="PriceLabel"> + <Property key="Caption" value="30"/> + </Widget> + + + <Widget type="AutoSizedButton" skin="MW_Button" name="BuyButton"> + <Property key="Caption" value="#{sBuy}"/> + </Widget> + + <Widget type="AutoSizedButton" skin="MW_Button" name="CancelButton"> + <Property key="Caption" value="#{sCancel}"/> + </Widget> + </Widget> </Widget> </MyGUI> From 4d496c11880d8f41dda20e5e2c0e36e60ab052e3 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Fri, 28 Sep 2012 17:02:27 +0200 Subject: [PATCH 008/255] correction1 --- apps/openmw/mwgui/tradewindow.cpp | 2 +- apps/openmw/mwgui/tradewindow.hpp | 2 +- apps/openmw/mwgui/travelwindow.cpp | 14 +++++++------- apps/openmw/mwrender/globalmap.cpp | 5 +++-- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index fc4220fc34..74cae380b3 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -16,7 +16,7 @@ namespace MWGui { TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_trade_window.layout", parWindowManager) - , ContainerBase(NULL) // no drag&drop + , ReferenceInterface(NULL) // no drag&drop , mCurrentBalance(0) { MyGUI::ScrollView* itemView; diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 4ec55045c5..7ca3a97b47 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -20,7 +20,7 @@ namespace MWGui namespace MWGui { - class TradeWindow : public ContainerBase, public WindowBase + class TradeWindow : public ReferenceInterface, public WindowBase { public: TradeWindow(MWBase::WindowManager& parWindowManager); diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 9e7b0a9751..f561a2c99a 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -79,7 +79,7 @@ namespace MWGui void TravelWindow::startTravel(const MWWorld::Ptr& actor) { center(); - mActor = actor; + mPtr = actor; clearDestinations(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); @@ -100,18 +100,18 @@ namespace MWGui addDestination (*iter); }*/ - for(int i = 0;i<mActor.get<ESM::NPC>()->base->mTransport.size();i++) + for(int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) { - std::string cellname = mActor.get<ESM::NPC>()->base->mTransport[i].mCellName; + std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName; int x,y; - MWBase::Environment::get().getWorld()->positionToIndex(mActor.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0], - mActor.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y); + MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0], + mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y); if(cellname == "") cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->name; addDestination(cellname); } updateLabels(); - + mPtr.get<ESM::NPC>()->base->mTransport[0]. mDestinationsView->setCanvasSize (MyGUI::IntSize(mDestinationsView->getWidth(), std::max(mDestinationsView->getHeight(), mCurrentY))); } @@ -126,7 +126,7 @@ namespace MWGui MWMechanics::Spells& spells = stats.getSpells(); spells.add (mSpellsWidgetMap.find(_sender)->second); mWindowManager.getTradeWindow()->addOrRemoveGold(-price); - startSpellBuying(mActor); + startSpellBuying(mPtr); MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); }*/ diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 5e0a63c77f..dd30a68f77 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -53,7 +53,8 @@ namespace MWRender { Ogre::Image image; - Ogre::uchar data[mWidth * mHeight * 3]; + std::vector<Ogre::uchar> data; + data.resize(mWidth * mHeight * 3); for (int x = mMinX; x <= mMaxX; ++x) { @@ -150,7 +151,7 @@ namespace MWRender } } - image.loadDynamicImage (data, mWidth, mHeight, Ogre::PF_B8G8R8); + image.loadDynamicImage (data.data(), mWidth, mHeight, Ogre::PF_B8G8R8); //image.save (mCacheDir + "/GlobalMap.png"); From c6fd864a76e010807a512e85f4a1c4a5078de4db Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 29 Sep 2012 10:02:46 +0200 Subject: [PATCH 009/255] Issue #61: Forgot to add some files --- apps/openmw/mwmechanics/alchemy.cpp | 7 +++++++ apps/openmw/mwmechanics/alchemy.hpp | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 apps/openmw/mwmechanics/alchemy.cpp create mode 100644 apps/openmw/mwmechanics/alchemy.hpp diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp new file mode 100644 index 0000000000..ea5cbe9650 --- /dev/null +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -0,0 +1,7 @@ + +#include "alchemy.hpp" + +void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) +{ + mNpc = npc; +} diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp new file mode 100644 index 0000000000..93c50f1ff4 --- /dev/null +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -0,0 +1,22 @@ +#ifndef GAME_MWMECHANICS_ALCHEMY_H +#define GAME_MWMECHANICS_ALCHEMY_H + +#include "../mwworld/ptr.hpp" + +namespace MWMechanics +{ + /// \brief Potion creatin via alchemy skill + class Alchemy + { + MWWorld::Ptr mNpc; + + public: + + void setAlchemist (const MWWorld::Ptr& npc); + ///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that + /// there is no alchemist (alchemy session has ended). + }; +} + +#endif + From 42f02f3ccd2b11e06868587871174661448865e3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sun, 30 Sep 2012 18:54:20 +0200 Subject: [PATCH 010/255] Issue #61: Re-implemented tool selection in Alchemy class --- apps/openmw/mwmechanics/alchemy.cpp | 39 +++++++++++++++++++++++++++++ apps/openmw/mwmechanics/alchemy.hpp | 14 +++++++++++ 2 files changed, 53 insertions(+) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index ea5cbe9650..0a01891909 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -1,7 +1,46 @@ #include "alchemy.hpp" +#include <algorithm> +#include <stdexcept> + +#include "../mwworld/containerstore.hpp" +#include "../mwworld/class.hpp" + void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) { mNpc = npc; + + mTools.resize (4); + + std::fill (mTools.begin(), mTools.end(), MWWorld::Ptr()); + + MWWorld::ContainerStore& store = MWWorld::Class::get (npc).getContainerStore (npc); + + for (MWWorld::ContainerStoreIterator iter (store.begin (MWWorld::ContainerStore::Type_Apparatus)); + iter!=store.end(); ++iter) + { + MWWorld::LiveCellRef<ESM::Apparatus>* ref = iter->get<ESM::Apparatus>(); + + int type = ref->base->data.type; + + if (type<0 || type>=static_cast<int> (mTools.size())) + throw std::runtime_error ("invalid apparatus type"); + + if (!mTools[type].isEmpty()) + if (ref->base->data.quality<=mTools[type].get<ESM::Apparatus>()->base->data.quality) + continue; + + mTools[type] = *iter; + } +} + +MWMechanics::Alchemy::TToolsIterator MWMechanics::Alchemy::beginTools() const +{ + return mTools.begin(); +} + +MWMechanics::Alchemy::TToolsIterator MWMechanics::Alchemy::endTools() const +{ + return mTools.end(); } diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 93c50f1ff4..fcaba90122 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -1,6 +1,8 @@ #ifndef GAME_MWMECHANICS_ALCHEMY_H #define GAME_MWMECHANICS_ALCHEMY_H +#include <vector> + #include "../mwworld/ptr.hpp" namespace MWMechanics @@ -8,13 +10,25 @@ namespace MWMechanics /// \brief Potion creatin via alchemy skill class Alchemy { + public: + + typedef std::vector<MWWorld::Ptr> TToolsContainer; + typedef TToolsContainer::const_iterator TToolsIterator; + + private: + MWWorld::Ptr mNpc; + TToolsContainer mTools; public: void setAlchemist (const MWWorld::Ptr& npc); ///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that /// there is no alchemist (alchemy session has ended). + + TToolsIterator beginTools() const; + + TToolsIterator endTools() const; }; } From 10c8360e07c1a31862f162d234c731829a0aba52 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sun, 30 Sep 2012 19:05:45 +0200 Subject: [PATCH 011/255] Issue #61: Replaced apparatus handling in alchemy GUI with new implementation in Alchemy class --- apps/openmw/mwgui/alchemywindow.cpp | 72 +++++++---------------------- apps/openmw/mwgui/alchemywindow.hpp | 9 ++-- 2 files changed, 21 insertions(+), 60 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 6fd88d5caa..26bd9668e6 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -28,7 +28,7 @@ namespace MWGui { AlchemyWindow::AlchemyWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_alchemy_window.layout", parWindowManager) - , ContainerBase(0) + , ContainerBase(0), mApparatus (4) { getWidget(mCreateButton, "CreateButton"); getWidget(mCancelButton, "CancelButton"); @@ -36,10 +36,10 @@ namespace MWGui getWidget(mIngredient2, "Ingredient2"); getWidget(mIngredient3, "Ingredient3"); getWidget(mIngredient4, "Ingredient4"); - getWidget(mApparatus1, "Apparatus1"); - getWidget(mApparatus2, "Apparatus2"); - getWidget(mApparatus3, "Apparatus3"); - getWidget(mApparatus4, "Apparatus4"); + getWidget(mApparatus[0], "Apparatus1"); + getWidget(mApparatus[1], "Apparatus2"); + getWidget(mApparatus[2], "Apparatus3"); + getWidget(mApparatus[3], "Apparatus4"); getWidget(mEffectsBox, "CreatedEffects"); getWidget(mNameEdit, "NameEdit"); @@ -70,7 +70,7 @@ namespace MWGui { // check if mortar & pestle is available (always needed) /// \todo check albemic, calcinator, retort (sometimes needed) - if (!mApparatus1->isUserString("ToolTipType")) + if (!mApparatus[0]->isUserString("ToolTipType")) { mWindowManager.messageBox("#{sNotifyMessage45}", std::vector<std::string>()); return; @@ -253,60 +253,22 @@ namespace MWGui void AlchemyWindow::open() { - openContainer(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr - setFilter(ContainerBase::Filter_Ingredients); + openContainer (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr + setFilter (ContainerBase::Filter_Ingredients); mAlchemy.setAlchemist (mPtr); - // pick the best available apparatus - MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr); + int index = 0; - MWWorld::Ptr bestAlbemic; - MWWorld::Ptr bestMortarPestle; - MWWorld::Ptr bestCalcinator; - MWWorld::Ptr bestRetort; - - for (MWWorld::ContainerStoreIterator it(store.begin(MWWorld::ContainerStore::Type_Apparatus)); - it != store.end(); ++it) + for (MWMechanics::Alchemy::TToolsIterator iter (mAlchemy.beginTools()); + iter!=mAlchemy.endTools() && index<static_cast<int> (mApparatus.size()); ++iter, ++index) { - MWWorld::LiveCellRef<ESM::Apparatus>* ref = it->get<ESM::Apparatus>(); - if (ref->base->data.type == ESM::Apparatus::Albemic - && (bestAlbemic.isEmpty() || ref->base->data.quality > bestAlbemic.get<ESM::Apparatus>()->base->data.quality)) - bestAlbemic = *it; - else if (ref->base->data.type == ESM::Apparatus::MortarPestle - && (bestMortarPestle.isEmpty() || ref->base->data.quality > bestMortarPestle.get<ESM::Apparatus>()->base->data.quality)) - bestMortarPestle = *it; - else if (ref->base->data.type == ESM::Apparatus::Calcinator - && (bestCalcinator.isEmpty() || ref->base->data.quality > bestCalcinator.get<ESM::Apparatus>()->base->data.quality)) - bestCalcinator = *it; - else if (ref->base->data.type == ESM::Apparatus::Retort - && (bestRetort.isEmpty() || ref->base->data.quality > bestRetort.get<ESM::Apparatus>()->base->data.quality)) - bestRetort = *it; - } - - if (!bestMortarPestle.isEmpty()) - { - mApparatus1->setUserString("ToolTipType", "ItemPtr"); - mApparatus1->setUserData(bestMortarPestle); - mApparatus1->setImageTexture(getIconPath(bestMortarPestle)); - } - if (!bestAlbemic.isEmpty()) - { - mApparatus2->setUserString("ToolTipType", "ItemPtr"); - mApparatus2->setUserData(bestAlbemic); - mApparatus2->setImageTexture(getIconPath(bestAlbemic)); - } - if (!bestCalcinator.isEmpty()) - { - mApparatus3->setUserString("ToolTipType", "ItemPtr"); - mApparatus3->setUserData(bestCalcinator); - mApparatus3->setImageTexture(getIconPath(bestCalcinator)); - } - if (!bestRetort.isEmpty()) - { - mApparatus4->setUserString("ToolTipType", "ItemPtr"); - mApparatus4->setUserData(bestRetort); - mApparatus4->setImageTexture(getIconPath(bestRetort)); + if (!iter->isEmpty()) + { + mApparatus[index]->setUserString ("ToolTipType", "ItemPtr"); + mApparatus[index]->setUserData (*iter); + mApparatus[index]->setImageTexture (getIconPath (*iter)); + } } } diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index 67378d7de1..5091fb57a8 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -1,6 +1,8 @@ #ifndef MWGUI_ALCHEMY_H #define MWGUI_ALCHEMY_H +#include <vector> + #include "../mwmechanics/alchemy.hpp" #include "window_base.hpp" @@ -25,11 +27,6 @@ namespace MWGui MyGUI::ImageBox* mIngredient3; MyGUI::ImageBox* mIngredient4; - MyGUI::ImageBox* mApparatus1; - MyGUI::ImageBox* mApparatus2; - MyGUI::ImageBox* mApparatus3; - MyGUI::ImageBox* mApparatus4; - MyGUI::Widget* mEffectsBox; MyGUI::EditBox* mNameEdit; @@ -52,6 +49,8 @@ namespace MWGui private: MWMechanics::Alchemy mAlchemy; + + std::vector<MyGUI::ImageBox *> mApparatus; }; } From 21493c2dbd9979e51673c589e88e95c6962be8b8 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Mon, 1 Oct 2012 23:33:07 +0200 Subject: [PATCH 012/255] added magic effect flags from Research wiki page --- apps/openmw/mwgui/spellcreationdialog.cpp | 10 +- apps/openmw/mwgui/tooltips.cpp | 2 +- apps/openmw/mwgui/widgets.cpp | 271 +--------------------- apps/openmw/mwgui/widgets.hpp | 8 - apps/openmw/mwrender/renderingmanager.cpp | 2 + components/esm/loadmgef.cpp | 157 +++++++++++++ components/esm/loadmgef.hpp | 21 +- 7 files changed, 186 insertions(+), 285 deletions(-) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 982416588e..133a01fe02 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -21,8 +21,8 @@ namespace bool sortMagicEffects (short id1, short id2) { - return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(MWGui::Widgets::MWSpellEffect::effectIDToString (id1))->getString() - < MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(MWGui::Widgets::MWSpellEffect::effectIDToString (id2))->getString(); + return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id1))->getString() + < MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id2))->getString(); } } @@ -74,7 +74,7 @@ namespace MWGui mEffectImage->setImageTexture (icon); - mEffectName->setCaptionWithReplacing("#{"+Widgets::MWSpellEffect::effectIDToString (effect->mIndex)+"}"); + mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}"); } void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender) @@ -179,14 +179,14 @@ namespace MWGui for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) { mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( - MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString()); + ESM::MagicEffect::effectIdToString (*it))->getString()); } mAvailableEffectsList->adjustSize (); for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) { std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( - MWGui::Widgets::MWSpellEffect::effectIDToString (*it))->getString(); + ESM::MagicEffect::effectIdToString (*it))->getString(); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); w->setUserData(*it); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 0ab242b62d..39afba7497 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -716,7 +716,7 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) { const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld ()->getStore ().magicEffects.find(id); - const std::string &name = Widgets::MWSpellEffect::effectIDToString (id); + const std::string &name = ESM::MagicEffect::effectIdToString (id); std::string icon = effect->mIcon; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 33aa1886c0..62e65be358 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -400,13 +400,13 @@ void MWSpellEffect::updateWidgets() std::string sec = " " + mWindowManager->getGameSettingString("ssecond", ""); std::string secs = " " + mWindowManager->getGameSettingString("sseconds", ""); - std::string effectIDStr = effectIDToString(mEffectParams.mEffectID); + std::string effectIDStr = ESM::MagicEffect::effectIdToString(mEffectParams.mEffectID); std::string spellLine = mWindowManager->getGameSettingString(effectIDStr, ""); - if (effectInvolvesSkill(effectIDStr) && mEffectParams.mSkill >= 0 && mEffectParams.mSkill < ESM::Skill::Length) + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) { spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[mEffectParams.mSkill], ""); } - if (effectInvolvesAttribute(effectIDStr) && mEffectParams.mAttribute >= 0 && mEffectParams.mAttribute < 8) + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) { static const char *attributes[8] = { "sAttributeStrength", @@ -421,7 +421,7 @@ void MWSpellEffect::updateWidgets() spellLine += " " + mWindowManager->getGameSettingString(attributes[mEffectParams.mAttribute], ""); } - if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && effectHasMagnitude(effectIDStr)) + if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) { if (mEffectParams.mMagnMin == mEffectParams.mMagnMax) spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + " " + ((mEffectParams.mMagnMin == 1) ? pt : pts); @@ -434,7 +434,7 @@ void MWSpellEffect::updateWidgets() // constant effects have no duration and no target if (!mEffectParams.mIsConstant) { - if (mEffectParams.mDuration >= 0 && effectHasDuration(effectIDStr)) + if (mEffectParams.mDuration >= 0 && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) { spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs); } @@ -463,267 +463,6 @@ void MWSpellEffect::updateWidgets() } } -std::string MWSpellEffect::effectIDToString(const short effectID) -{ - // Map effect ID to GMST name - // http://www.uesp.net/morrow/hints/mweffects.shtml - std::map<short, std::string> names; - names[85] ="sEffectAbsorbAttribute"; - names[88] ="sEffectAbsorbFatigue"; - names[86] ="sEffectAbsorbHealth"; - names[87] ="sEffectAbsorbSpellPoints"; - names[89] ="sEffectAbsorbSkill"; - names[63] ="sEffectAlmsiviIntervention"; - names[47] ="sEffectBlind"; - names[123] ="sEffectBoundBattleAxe"; - names[129] ="sEffectBoundBoots"; - names[127] ="sEffectBoundCuirass"; - names[120] ="sEffectBoundDagger"; - names[131] ="sEffectBoundGloves"; - names[128] ="sEffectBoundHelm"; - names[125] ="sEffectBoundLongbow"; - names[121] ="sEffectBoundLongsword"; - names[122] ="sEffectBoundMace"; - names[130] ="sEffectBoundShield"; - names[124] ="sEffectBoundSpear"; - names[7] ="sEffectBurden"; - names[50] ="sEffectCalmCreature"; - names[49] ="sEffectCalmHumanoid"; - names[40] ="sEffectChameleon"; - names[44] ="sEffectCharm"; - names[118] ="sEffectCommandCreatures"; - names[119] ="sEffectCommandHumanoids"; - names[132] ="sEffectCorpus"; // NB this typo. (bethesda made it) - names[70] ="sEffectCureBlightDisease"; - names[69] ="sEffectCureCommonDisease"; - names[71] ="sEffectCureCorprusDisease"; - names[73] ="sEffectCureParalyzation"; - names[72] ="sEffectCurePoison"; - names[22] ="sEffectDamageAttribute"; - names[25] ="sEffectDamageFatigue"; - names[23] ="sEffectDamageHealth"; - names[24] ="sEffectDamageMagicka"; - names[26] ="sEffectDamageSkill"; - names[54] ="sEffectDemoralizeCreature"; - names[53] ="sEffectDemoralizeHumanoid"; - names[64] ="sEffectDetectAnimal"; - names[65] ="sEffectDetectEnchantment"; - names[66] ="sEffectDetectKey"; - names[38] ="sEffectDisintegrateArmor"; - names[37] ="sEffectDisintegrateWeapon"; - names[57] ="sEffectDispel"; - names[62] ="sEffectDivineIntervention"; - names[17] ="sEffectDrainAttribute"; - names[20] ="sEffectDrainFatigue"; - names[18] ="sEffectDrainHealth"; - names[19] ="sEffectDrainSpellpoints"; - names[21] ="sEffectDrainSkill"; - names[8] ="sEffectFeather"; - names[14] ="sEffectFireDamage"; - names[4] ="sEffectFireShield"; - names[117] ="sEffectFortifyAttackBonus"; - names[79] ="sEffectFortifyAttribute"; - names[82] ="sEffectFortifyFatigue"; - names[80] ="sEffectFortifyHealth"; - names[81] ="sEffectFortifySpellpoints"; - names[84] ="sEffectFortifyMagickaMultiplier"; - names[83] ="sEffectFortifySkill"; - names[52] ="sEffectFrenzyCreature"; - names[51] ="sEffectFrenzyHumanoid"; - names[16] ="sEffectFrostDamage"; - names[6] ="sEffectFrostShield"; - names[39] ="sEffectInvisibility"; - names[9] ="sEffectJump"; - names[10] ="sEffectLevitate"; - names[41] ="sEffectLight"; - names[5] ="sEffectLightningShield"; - names[12] ="sEffectLock"; - names[60] ="sEffectMark"; - names[43] ="sEffectNightEye"; - names[13] ="sEffectOpen"; - names[45] ="sEffectParalyze"; - names[27] ="sEffectPoison"; - names[56] ="sEffectRallyCreature"; - names[55] ="sEffectRallyHumanoid"; - names[61] ="sEffectRecall"; - names[68] ="sEffectReflect"; - names[100] ="sEffectRemoveCurse"; - names[95] ="sEffectResistBlightDisease"; - names[94] ="sEffectResistCommonDisease"; - names[96] ="sEffectResistCorprusDisease"; - names[90] ="sEffectResistFire"; - names[91] ="sEffectResistFrost"; - names[93] ="sEffectResistMagicka"; - names[98] ="sEffectResistNormalWeapons"; - names[99] ="sEffectResistParalysis"; - names[97] ="sEffectResistPoison"; - names[92] ="sEffectResistShock"; - names[74] ="sEffectRestoreAttribute"; - names[77] ="sEffectRestoreFatigue"; - names[75] ="sEffectRestoreHealth"; - names[76] ="sEffectRestoreSpellPoints"; - names[78] ="sEffectRestoreSkill"; - names[42] ="sEffectSanctuary"; - names[3] ="sEffectShield"; - names[15] ="sEffectShockDamage"; - names[46] ="sEffectSilence"; - names[11] ="sEffectSlowFall"; - names[58] ="sEffectSoultrap"; - names[48] ="sEffectSound"; - names[67] ="sEffectSpellAbsorption"; - names[136] ="sEffectStuntedMagicka"; - names[106] ="sEffectSummonAncestralGhost"; - names[110] ="sEffectSummonBonelord"; - names[108] ="sEffectSummonLeastBonewalker"; - names[134] ="sEffectSummonCenturionSphere"; - names[103] ="sEffectSummonClannfear"; - names[104] ="sEffectSummonDaedroth"; - names[105] ="sEffectSummonDremora"; - names[114] ="sEffectSummonFlameAtronach"; - names[115] ="sEffectSummonFrostAtronach"; - names[113] ="sEffectSummonGoldenSaint"; - names[109] ="sEffectSummonGreaterBonewalker"; - names[112] ="sEffectSummonHunger"; - names[102] ="sEffectSummonScamp"; - names[107] ="sEffectSummonSkeletalMinion"; - names[116] ="sEffectSummonStormAtronach"; - names[111] ="sEffectSummonWingedTwilight"; - names[135] ="sEffectSunDamage"; - names[1] ="sEffectSwiftSwim"; - names[59] ="sEffectTelekinesis"; - names[101] ="sEffectTurnUndead"; - names[133] ="sEffectVampirism"; - names[0] ="sEffectWaterBreathing"; - names[2] ="sEffectWaterWalking"; - names[33] ="sEffectWeaknesstoBlightDisease"; - names[32] ="sEffectWeaknesstoCommonDisease"; - names[34] ="sEffectWeaknesstoCorprusDisease"; - names[28] ="sEffectWeaknesstoFire"; - names[29] ="sEffectWeaknesstoFrost"; - names[31] ="sEffectWeaknesstoMagicka"; - names[36] ="sEffectWeaknesstoNormalWeapons"; - names[35] ="sEffectWeaknesstoPoison"; - names[30] ="sEffectWeaknesstoShock"; - - // bloodmoon - names[138] ="sEffectSummonCreature01"; - names[139] ="sEffectSummonCreature02"; - names[140] ="sEffectSummonCreature03"; - names[141] ="sEffectSummonCreature04"; - names[142] ="sEffectSummonCreature05"; - - // tribunal - names[137] ="sEffectSummonFabricant"; - - assert(names.find(effectID) != names.end() && "Unimplemented effect type"); - - return names[effectID]; -} - -bool MWSpellEffect::effectHasDuration(const std::string& effect) -{ - // lists effects that have no duration (e.g. open lock) - std::vector<std::string> effectsWithoutDuration; - effectsWithoutDuration.push_back("sEffectOpen"); - effectsWithoutDuration.push_back("sEffectLock"); - effectsWithoutDuration.push_back("sEffectDispel"); - effectsWithoutDuration.push_back("sEffectSunDamage"); - effectsWithoutDuration.push_back("sEffectCorpus"); - effectsWithoutDuration.push_back("sEffectVampirism"); - effectsWithoutDuration.push_back("sEffectMark"); - effectsWithoutDuration.push_back("sEffectRecall"); - effectsWithoutDuration.push_back("sEffectDivineIntervention"); - effectsWithoutDuration.push_back("sEffectAlmsiviIntervention"); - effectsWithoutDuration.push_back("sEffectCureCommonDisease"); - effectsWithoutDuration.push_back("sEffectCureBlightDisease"); - effectsWithoutDuration.push_back("sEffectCureCorprusDisease"); - effectsWithoutDuration.push_back("sEffectCurePoison"); - effectsWithoutDuration.push_back("sEffectCureParalyzation"); - effectsWithoutDuration.push_back("sEffectRemoveCurse"); - effectsWithoutDuration.push_back("sEffectRestoreAttribute"); - - return (std::find(effectsWithoutDuration.begin(), effectsWithoutDuration.end(), effect) == effectsWithoutDuration.end()); -} - -bool MWSpellEffect::effectHasMagnitude(const std::string& effect) -{ - // lists effects that have no magnitude (e.g. invisiblity) - std::vector<std::string> effectsWithoutMagnitude; - effectsWithoutMagnitude.push_back("sEffectInvisibility"); - effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); - effectsWithoutMagnitude.push_back("sEffectParalyze"); - effectsWithoutMagnitude.push_back("sEffectSoultrap"); - effectsWithoutMagnitude.push_back("sEffectSilence"); - effectsWithoutMagnitude.push_back("sEffectParalyze"); - effectsWithoutMagnitude.push_back("sEffectInvisibility"); - effectsWithoutMagnitude.push_back("sEffectWaterWalking"); - effectsWithoutMagnitude.push_back("sEffectWaterBreathing"); - effectsWithoutMagnitude.push_back("sEffectSummonScamp"); - effectsWithoutMagnitude.push_back("sEffectSummonClannfear"); - effectsWithoutMagnitude.push_back("sEffectSummonDaedroth"); - effectsWithoutMagnitude.push_back("sEffectSummonDremora"); - effectsWithoutMagnitude.push_back("sEffectSummonAncestralGhost"); - effectsWithoutMagnitude.push_back("sEffectSummonSkeletalMinion"); - effectsWithoutMagnitude.push_back("sEffectSummonBonewalker"); - effectsWithoutMagnitude.push_back("sEffectSummonGreaterBonewalker"); - effectsWithoutMagnitude.push_back("sEffectSummonBonelord"); - effectsWithoutMagnitude.push_back("sEffectSummonWingedTwilight"); - effectsWithoutMagnitude.push_back("sEffectSummonHunger"); - effectsWithoutMagnitude.push_back("sEffectSummonGoldenSaint"); - effectsWithoutMagnitude.push_back("sEffectSummonFlameAtronach"); - effectsWithoutMagnitude.push_back("sEffectSummonFrostAtronach"); - effectsWithoutMagnitude.push_back("sEffectSummonStormAtronach"); - effectsWithoutMagnitude.push_back("sEffectSummonCenturionSphere"); - effectsWithoutMagnitude.push_back("sEffectBoundDagger"); - effectsWithoutMagnitude.push_back("sEffectBoundLongsword"); - effectsWithoutMagnitude.push_back("sEffectBoundMace"); - effectsWithoutMagnitude.push_back("sEffectBoundBattleAxe"); - effectsWithoutMagnitude.push_back("sEffectBoundSpear"); - effectsWithoutMagnitude.push_back("sEffectBoundLongbow"); - effectsWithoutMagnitude.push_back("sEffectBoundCuirass"); - effectsWithoutMagnitude.push_back("sEffectBoundHelm"); - effectsWithoutMagnitude.push_back("sEffectBoundBoots"); - effectsWithoutMagnitude.push_back("sEffectBoundShield"); - effectsWithoutMagnitude.push_back("sEffectBoundGloves"); - effectsWithoutMagnitude.push_back("sEffectStuntedMagicka"); - effectsWithoutMagnitude.push_back("sEffectMark"); - effectsWithoutMagnitude.push_back("sEffectRecall"); - effectsWithoutMagnitude.push_back("sEffectDivineIntervention"); - effectsWithoutMagnitude.push_back("sEffectAlmsiviIntervention"); - effectsWithoutMagnitude.push_back("sEffectCureCommonDisease"); - effectsWithoutMagnitude.push_back("sEffectCureBlightDisease"); - effectsWithoutMagnitude.push_back("sEffectCureCorprusDisease"); - effectsWithoutMagnitude.push_back("sEffectCurePoison"); - effectsWithoutMagnitude.push_back("sEffectCureParalyzation"); - effectsWithoutMagnitude.push_back("sEffectRemoveCurse"); - effectsWithoutMagnitude.push_back("sEffectSummonCreature01"); - effectsWithoutMagnitude.push_back("sEffectSummonCreature02"); - effectsWithoutMagnitude.push_back("sEffectSummonCreature03"); - effectsWithoutMagnitude.push_back("sEffectSummonCreature04"); - effectsWithoutMagnitude.push_back("sEffectSummonCreature05"); - effectsWithoutMagnitude.push_back("sEffectSummonFabricant"); - - return (std::find(effectsWithoutMagnitude.begin(), effectsWithoutMagnitude.end(), effect) == effectsWithoutMagnitude.end()); -} - -bool MWSpellEffect::effectInvolvesAttribute (const std::string& effect) -{ - return (effect == "sEffectRestoreAttribute" - || effect == "sEffectAbsorbAttribute" - || effect == "sEffectDrainAttribute" - || effect == "sEffectFortifyAttribute" - || effect == "sEffectDamageAttribute"); -} - -bool MWSpellEffect::effectInvolvesSkill (const std::string& effect) -{ - return (effect == "sEffectRestoreSkill" - || effect == "sEffectAbsorbSkill" - || effect == "sEffectDrainSkill" - || effect == "sEffectFortifySkill" - || effect == "sEffectDamageSkill"); -} - MWSpellEffect::~MWSpellEffect() { } diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index cc733122cd..0a15e8e1fb 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -249,14 +249,6 @@ namespace MWGui void setWindowManager(MWBase::WindowManager* parWindowManager) { mWindowManager = parWindowManager; } void setSpellEffect(const SpellEffectParams& params); - static std::string effectIDToString(const short effectID); - - /// \todo Remove all of these! The information can be obtained via the ESM::MagicEffect's flags! - static bool effectHasMagnitude (const std::string& effect); - static bool effectHasDuration (const std::string& effect); - static bool effectInvolvesAttribute (const std::string& effect); - static bool effectInvolvesSkill (const std::string& effect); - int getRequestedWidth() const { return mRequestedWidth; } protected: diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index c937c9894f..21299e25c1 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -180,6 +180,8 @@ RenderingManager::~RenderingManager () delete mOcclusionQuery; delete mCompositors; delete mWater; + + delete mFactory; } MWRender::SkyManager* RenderingManager::getSkyManager() diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index be588fbb01..9542140367 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -79,4 +79,161 @@ void MagicEffect::save(ESMWriter &esm) esm.writeHNOString("DESC", mDescription); } +std::string MagicEffect::effectIdToString(short effectID) +{ + // Map effect ID to GMST name + // http://www.uesp.net/morrow/hints/mweffects.shtml + std::map<short, std::string> names; + names[85] ="sEffectAbsorbAttribute"; + names[88] ="sEffectAbsorbFatigue"; + names[86] ="sEffectAbsorbHealth"; + names[87] ="sEffectAbsorbSpellPoints"; + names[89] ="sEffectAbsorbSkill"; + names[63] ="sEffectAlmsiviIntervention"; + names[47] ="sEffectBlind"; + names[123] ="sEffectBoundBattleAxe"; + names[129] ="sEffectBoundBoots"; + names[127] ="sEffectBoundCuirass"; + names[120] ="sEffectBoundDagger"; + names[131] ="sEffectBoundGloves"; + names[128] ="sEffectBoundHelm"; + names[125] ="sEffectBoundLongbow"; + names[121] ="sEffectBoundLongsword"; + names[122] ="sEffectBoundMace"; + names[130] ="sEffectBoundShield"; + names[124] ="sEffectBoundSpear"; + names[7] ="sEffectBurden"; + names[50] ="sEffectCalmCreature"; + names[49] ="sEffectCalmHumanoid"; + names[40] ="sEffectChameleon"; + names[44] ="sEffectCharm"; + names[118] ="sEffectCommandCreatures"; + names[119] ="sEffectCommandHumanoids"; + names[132] ="sEffectCorpus"; // NB this typo. (bethesda made it) + names[70] ="sEffectCureBlightDisease"; + names[69] ="sEffectCureCommonDisease"; + names[71] ="sEffectCureCorprusDisease"; + names[73] ="sEffectCureParalyzation"; + names[72] ="sEffectCurePoison"; + names[22] ="sEffectDamageAttribute"; + names[25] ="sEffectDamageFatigue"; + names[23] ="sEffectDamageHealth"; + names[24] ="sEffectDamageMagicka"; + names[26] ="sEffectDamageSkill"; + names[54] ="sEffectDemoralizeCreature"; + names[53] ="sEffectDemoralizeHumanoid"; + names[64] ="sEffectDetectAnimal"; + names[65] ="sEffectDetectEnchantment"; + names[66] ="sEffectDetectKey"; + names[38] ="sEffectDisintegrateArmor"; + names[37] ="sEffectDisintegrateWeapon"; + names[57] ="sEffectDispel"; + names[62] ="sEffectDivineIntervention"; + names[17] ="sEffectDrainAttribute"; + names[20] ="sEffectDrainFatigue"; + names[18] ="sEffectDrainHealth"; + names[19] ="sEffectDrainSpellpoints"; + names[21] ="sEffectDrainSkill"; + names[8] ="sEffectFeather"; + names[14] ="sEffectFireDamage"; + names[4] ="sEffectFireShield"; + names[117] ="sEffectFortifyAttackBonus"; + names[79] ="sEffectFortifyAttribute"; + names[82] ="sEffectFortifyFatigue"; + names[80] ="sEffectFortifyHealth"; + names[81] ="sEffectFortifySpellpoints"; + names[84] ="sEffectFortifyMagickaMultiplier"; + names[83] ="sEffectFortifySkill"; + names[52] ="sEffectFrenzyCreature"; + names[51] ="sEffectFrenzyHumanoid"; + names[16] ="sEffectFrostDamage"; + names[6] ="sEffectFrostShield"; + names[39] ="sEffectInvisibility"; + names[9] ="sEffectJump"; + names[10] ="sEffectLevitate"; + names[41] ="sEffectLight"; + names[5] ="sEffectLightningShield"; + names[12] ="sEffectLock"; + names[60] ="sEffectMark"; + names[43] ="sEffectNightEye"; + names[13] ="sEffectOpen"; + names[45] ="sEffectParalyze"; + names[27] ="sEffectPoison"; + names[56] ="sEffectRallyCreature"; + names[55] ="sEffectRallyHumanoid"; + names[61] ="sEffectRecall"; + names[68] ="sEffectReflect"; + names[100] ="sEffectRemoveCurse"; + names[95] ="sEffectResistBlightDisease"; + names[94] ="sEffectResistCommonDisease"; + names[96] ="sEffectResistCorprusDisease"; + names[90] ="sEffectResistFire"; + names[91] ="sEffectResistFrost"; + names[93] ="sEffectResistMagicka"; + names[98] ="sEffectResistNormalWeapons"; + names[99] ="sEffectResistParalysis"; + names[97] ="sEffectResistPoison"; + names[92] ="sEffectResistShock"; + names[74] ="sEffectRestoreAttribute"; + names[77] ="sEffectRestoreFatigue"; + names[75] ="sEffectRestoreHealth"; + names[76] ="sEffectRestoreSpellPoints"; + names[78] ="sEffectRestoreSkill"; + names[42] ="sEffectSanctuary"; + names[3] ="sEffectShield"; + names[15] ="sEffectShockDamage"; + names[46] ="sEffectSilence"; + names[11] ="sEffectSlowFall"; + names[58] ="sEffectSoultrap"; + names[48] ="sEffectSound"; + names[67] ="sEffectSpellAbsorption"; + names[136] ="sEffectStuntedMagicka"; + names[106] ="sEffectSummonAncestralGhost"; + names[110] ="sEffectSummonBonelord"; + names[108] ="sEffectSummonLeastBonewalker"; + names[134] ="sEffectSummonCenturionSphere"; + names[103] ="sEffectSummonClannfear"; + names[104] ="sEffectSummonDaedroth"; + names[105] ="sEffectSummonDremora"; + names[114] ="sEffectSummonFlameAtronach"; + names[115] ="sEffectSummonFrostAtronach"; + names[113] ="sEffectSummonGoldenSaint"; + names[109] ="sEffectSummonGreaterBonewalker"; + names[112] ="sEffectSummonHunger"; + names[102] ="sEffectSummonScamp"; + names[107] ="sEffectSummonSkeletalMinion"; + names[116] ="sEffectSummonStormAtronach"; + names[111] ="sEffectSummonWingedTwilight"; + names[135] ="sEffectSunDamage"; + names[1] ="sEffectSwiftSwim"; + names[59] ="sEffectTelekinesis"; + names[101] ="sEffectTurnUndead"; + names[133] ="sEffectVampirism"; + names[0] ="sEffectWaterBreathing"; + names[2] ="sEffectWaterWalking"; + names[33] ="sEffectWeaknesstoBlightDisease"; + names[32] ="sEffectWeaknesstoCommonDisease"; + names[34] ="sEffectWeaknesstoCorprusDisease"; + names[28] ="sEffectWeaknesstoFire"; + names[29] ="sEffectWeaknesstoFrost"; + names[31] ="sEffectWeaknesstoMagicka"; + names[36] ="sEffectWeaknesstoNormalWeapons"; + names[35] ="sEffectWeaknesstoPoison"; + names[30] ="sEffectWeaknesstoShock"; + + // bloodmoon + names[138] ="sEffectSummonCreature01"; + names[139] ="sEffectSummonCreature02"; + names[140] ="sEffectSummonCreature03"; + names[141] ="sEffectSummonCreature04"; + names[142] ="sEffectSummonCreature05"; + + // tribunal + names[137] ="sEffectSummonFabricant"; + + assert(names.find(effectID) != names.end() && "Unimplemented effect type"); + + return names[effectID]; +} + } diff --git a/components/esm/loadmgef.hpp b/components/esm/loadmgef.hpp index 861f66be05..abf4ab5451 100644 --- a/components/esm/loadmgef.hpp +++ b/components/esm/loadmgef.hpp @@ -13,11 +13,19 @@ struct MagicEffect { enum Flags { - NoDuration = 0x4, - SpellMaking = 0x0200, - Enchanting = 0x0400, - Negative = 0x0800 // A harmful effect. Will determine whether - // eg. NPCs regard this spell as an attack. + TargetSkill = 0x1, // Affects a specific skill, which is specified elsewhere in the effect structure. + TargetAttribute = 0x2, // Affects a specific attribute, which is specified elsewhere in the effect structure. + NoDuration = 0x4, // Has no duration. Only runs effect once on cast. + NoMagnitude = 0x8, // Has no magnitude. + Negative = 0x10, // Counts as a negative effect. Interpreted as useful for attack, and is treated as a bad effect in alchemy. + ContinuousVfx = 0x20, // The effect's hit particle VFX repeats for the full duration of the spell, rather than occuring once on hit. + CastSelf = 0x40, // Allows range - cast on self. + CastTouch = 0x80, // Allows range - cast on touch. + CastTarget = 0x100, // Allows range - cast on target. + UncappedDamage = 0x1000, // Negates multiple cap behaviours. Allows an effect to reduce an attribute below zero; removes the normal minimum effect duration of 1 second. + NonRecastable = 0x4000, // Does not land if parent spell is already affecting target. Shows "you cannot re-cast" message for self target. + Unreflectable = 0x10000, // Cannot be reflected, the effect always lands normally. + CasterLinked = 0x20000 // Must quench if caster is dead, or not an NPC/creature. Not allowed in containter/door trap spells. }; struct MEDTstruct @@ -30,6 +38,9 @@ struct MagicEffect float mSpeed, mSize, mSizeCap; }; // 36 bytes + static std::string effectIdToString(short effectID); + + MEDTstruct mData; std::string mIcon, mParticle; // Textures From 1cc2c2055f41a0d68757972fb27e077290490360 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 2 Oct 2012 10:20:26 +0200 Subject: [PATCH 013/255] Issue #61: Implemented basic ingredient handling in Alchemy class --- apps/openmw/mwmechanics/alchemy.cpp | 52 +++++++++++++++++++++++++++++ apps/openmw/mwmechanics/alchemy.hpp | 22 +++++++++++- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index c7e5da70ae..6d3deed3c4 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -11,6 +11,10 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) { mNpc = npc; + mIngredients.resize (4); + + std::fill (mIngredients.begin(), mIngredients.end(), MWWorld::Ptr()); + mTools.resize (4); std::fill (mTools.begin(), mTools.end(), MWWorld::Ptr()); @@ -44,3 +48,51 @@ MWMechanics::Alchemy::TToolsIterator MWMechanics::Alchemy::endTools() const { return mTools.end(); } + +MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::beginIngredients() const +{ + return mIngredients.begin(); +} + +MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::endIngredients() const +{ + return mIngredients.end(); +} + +void MWMechanics::Alchemy::clear() +{ + mNpc = MWWorld::Ptr(); + mTools.clear(); + mIngredients.clear(); +} + +int MWMechanics::Alchemy::addIngredient (const MWWorld::Ptr& ingredient) +{ + // find a free slot + int slot = -1; + + for (int i=0; i<static_cast<int> (mIngredients.size()); ++i) + if (mIngredients[i].isEmpty()) + { + slot = i; + break; + } + + if (slot==-1) + return -1; + + for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter) + if (!iter->isEmpty() && ingredient.get<ESM::Ingredient>()==iter->get<ESM::Ingredient>()) + return -1; + + mIngredients[slot] = ingredient; + + return slot; +} + +void MWMechanics::Alchemy::removeIngredient (int index) +{ + if (index>=0 && index<static_cast<int> (mIngredients.size())) + mIngredients[index] = MWWorld::Ptr(); +} + diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index fcaba90122..7c3cf9e680 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -7,7 +7,7 @@ namespace MWMechanics { - /// \brief Potion creatin via alchemy skill + /// \brief Potion creation via alchemy skill class Alchemy { public: @@ -15,10 +15,14 @@ namespace MWMechanics typedef std::vector<MWWorld::Ptr> TToolsContainer; typedef TToolsContainer::const_iterator TToolsIterator; + typedef std::vector<MWWorld::Ptr> TIngredientsContainer; + typedef TIngredientsContainer::const_iterator TIngredientsIterator; + private: MWWorld::Ptr mNpc; TToolsContainer mTools; + TIngredientsContainer mIngredients; public: @@ -29,6 +33,22 @@ namespace MWMechanics TToolsIterator beginTools() const; TToolsIterator endTools() const; + + TIngredientsIterator beginIngredients() const; + + TIngredientsIterator endIngredients() const; + + void clear(); + ///< Remove alchemist, tools and ingredients. + + int addIngredient (const MWWorld::Ptr& ingredient); + ///< Add ingredient into the next free slot. + /// + /// \return Slot index or -1, if adding failed because of no free slot or the ingredient type being + /// listed already. + + void removeIngredient (int index); + ///< Remove ingredient from slot (calling this function on an empty slot is a no-op). }; } From 14833a4c3abbae15a5d000e00f80649f8117acb1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 2 Oct 2012 10:20:49 +0200 Subject: [PATCH 014/255] Issue #61: More robust tools handling in alchemy window --- apps/openmw/mwgui/alchemywindow.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 93eee60ee4..2aa46fda0e 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -62,6 +62,8 @@ namespace MWGui void AlchemyWindow::onCancelButtonClicked(MyGUI::Widget* _sender) { + mAlchemy.clear(); + mWindowManager.removeGuiMode(GM_Alchemy); mWindowManager.removeGuiMode(GM_Inventory); } @@ -265,9 +267,9 @@ namespace MWGui { if (!iter->isEmpty()) { - mApparatus[index]->setUserString ("ToolTipType", "ItemPtr"); - mApparatus[index]->setUserData (*iter); - mApparatus[index]->setImageTexture (getIconPath (*iter)); + mApparatus.at (index)->setUserString ("ToolTipType", "ItemPtr"); + mApparatus.at (index)->setUserData (*iter); + mApparatus.at (index)->setImageTexture (getIconPath (*iter)); } } } From 332039da10d303b611d85298a690ddf23392fbf5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 2 Oct 2012 10:29:47 +0200 Subject: [PATCH 015/255] Issue #61: replaced 4 ingredient member variables with vector in alchemy GUI --- apps/openmw/mwgui/alchemywindow.cpp | 148 ++++++++-------------------- apps/openmw/mwgui/alchemywindow.hpp | 6 +- 2 files changed, 44 insertions(+), 110 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 2aa46fda0e..cef5d6e2e7 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -28,14 +28,14 @@ namespace MWGui { AlchemyWindow::AlchemyWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_alchemy_window.layout", parWindowManager) - , ContainerBase(0), mApparatus (4) + , ContainerBase(0), mApparatus (4), mIngredients (4) { getWidget(mCreateButton, "CreateButton"); getWidget(mCancelButton, "CancelButton"); - getWidget(mIngredient1, "Ingredient1"); - getWidget(mIngredient2, "Ingredient2"); - getWidget(mIngredient3, "Ingredient3"); - getWidget(mIngredient4, "Ingredient4"); + getWidget(mIngredients[0], "Ingredient1"); + getWidget(mIngredients[1], "Ingredient2"); + getWidget(mIngredients[2], "Ingredient3"); + getWidget(mIngredients[3], "Ingredient4"); getWidget(mApparatus[0], "Apparatus1"); getWidget(mApparatus[1], "Apparatus2"); getWidget(mApparatus[2], "Apparatus3"); @@ -43,10 +43,10 @@ namespace MWGui getWidget(mEffectsBox, "CreatedEffects"); getWidget(mNameEdit, "NameEdit"); - mIngredient1->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); - mIngredient2->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); - mIngredient3->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); - mIngredient4->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); + mIngredients[0]->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); + mIngredients[1]->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); + mIngredients[2]->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); + mIngredients[3]->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onIngredientSelected); mCreateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCreateButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &AlchemyWindow::onCancelButtonClicked); @@ -80,14 +80,10 @@ namespace MWGui // make sure 2 or more ingredients were selected int numIngreds = 0; - if (mIngredient1->isUserString("ToolTipType")) - ++numIngreds; - if (mIngredient2->isUserString("ToolTipType")) - ++numIngreds; - if (mIngredient3->isUserString("ToolTipType")) - ++numIngreds; - if (mIngredient4->isUserString("ToolTipType")) - ++numIngreds; + for (int i=0; i<4; ++i) + if (mIngredients[i]->isUserString("ToolTipType")) + ++numIngreds; + if (numIngreds < 2) { mWindowManager.messageBox("#{sNotifyMessage6a}", std::vector<std::string>()); @@ -138,14 +134,9 @@ namespace MWGui // note by scrawl: not rounding down here, I can't imagine a created potion to // have 0 weight when using ingredients with 0.1 weight respectively float weight = 0; - if (mIngredient1->isUserString("ToolTipType")) - weight += mIngredient1->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>()->base->mData.mWeight; - if (mIngredient2->isUserString("ToolTipType")) - weight += mIngredient2->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>()->base->mData.mWeight; - if (mIngredient3->isUserString("ToolTipType")) - weight += mIngredient3->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>()->base->mData.mWeight; - if (mIngredient4->isUserString("ToolTipType")) - weight += mIngredient4->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>()->base->mData.mWeight; + for (int i=0; i<4; ++i) + if (mIngredients[i]->isUserString("ToolTipType")) + weight += mIngredients[i]->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>()->base->mData.mWeight; newPotion.mData.mWeight = weight / float(numIngreds); newPotion.mData.mValue = 100; /// \todo @@ -222,34 +213,15 @@ namespace MWGui } // reduce count of the ingredients - if (mIngredient1->isUserString("ToolTipType")) - { - MWWorld::Ptr ingred = *mIngredient1->getUserData<MWWorld::Ptr>(); - ingred.getRefData().setCount(ingred.getRefData().getCount()-1); - if (ingred.getRefData().getCount() == 0) - removeIngredient(mIngredient1); - } - if (mIngredient2->isUserString("ToolTipType")) - { - MWWorld::Ptr ingred = *mIngredient2->getUserData<MWWorld::Ptr>(); - ingred.getRefData().setCount(ingred.getRefData().getCount()-1); - if (ingred.getRefData().getCount() == 0) - removeIngredient(mIngredient2); - } - if (mIngredient3->isUserString("ToolTipType")) - { - MWWorld::Ptr ingred = *mIngredient3->getUserData<MWWorld::Ptr>(); - ingred.getRefData().setCount(ingred.getRefData().getCount()-1); - if (ingred.getRefData().getCount() == 0) - removeIngredient(mIngredient3); - } - if (mIngredient4->isUserString("ToolTipType")) - { - MWWorld::Ptr ingred = *mIngredient4->getUserData<MWWorld::Ptr>(); - ingred.getRefData().setCount(ingred.getRefData().getCount()-1); - if (ingred.getRefData().getCount() == 0) - removeIngredient(mIngredient4); + for (int i=0; i<4; ++i) + if (mIngredients[i]->isUserString("ToolTipType")) + { + MWWorld::Ptr ingred = *mIngredients[i]->getUserData<MWWorld::Ptr>(); + ingred.getRefData().setCount(ingred.getRefData().getCount()-1); + if (ingred.getRefData().getCount() == 0) + removeIngredient(mIngredients[i]); } + update(); } @@ -289,45 +261,24 @@ namespace MWGui // (which could happen if two similiar ingredients don't stack because of script / owner) bool alreadyAdded = false; std::string name = MWWorld::Class::get(item).getName(item); - if (mIngredient1->isUserString("ToolTipType")) - { - MWWorld::Ptr item2 = *mIngredient1->getUserData<MWWorld::Ptr>(); - std::string name2 = MWWorld::Class::get(item2).getName(item2); - if (name == name2) - alreadyAdded = true; - } - if (mIngredient2->isUserString("ToolTipType")) - { - MWWorld::Ptr item2 = *mIngredient2->getUserData<MWWorld::Ptr>(); - std::string name2 = MWWorld::Class::get(item2).getName(item2); - if (name == name2) - alreadyAdded = true; - } - if (mIngredient3->isUserString("ToolTipType")) - { - MWWorld::Ptr item2 = *mIngredient3->getUserData<MWWorld::Ptr>(); - std::string name2 = MWWorld::Class::get(item2).getName(item2); - if (name == name2) - alreadyAdded = true; - } - if (mIngredient4->isUserString("ToolTipType")) - { - MWWorld::Ptr item2 = *mIngredient4->getUserData<MWWorld::Ptr>(); - std::string name2 = MWWorld::Class::get(item2).getName(item2); - if (name == name2) - alreadyAdded = true; - } + for (int i=0; i<4; ++i) + if (mIngredients[i]->isUserString("ToolTipType")) + { + MWWorld::Ptr item2 = *mIngredients[i]->getUserData<MWWorld::Ptr>(); + std::string name2 = MWWorld::Class::get(item2).getName(item2); + if (name == name2) + alreadyAdded = true; + } + if (alreadyAdded) return; - if (!mIngredient1->isUserString("ToolTipType")) - add = mIngredient1; - if (add == NULL && !mIngredient2->isUserString("ToolTipType")) - add = mIngredient2; - if (add == NULL && !mIngredient3->isUserString("ToolTipType")) - add = mIngredient3; - if (add == NULL && !mIngredient4->isUserString("ToolTipType")) - add = mIngredient4; + for (int i=0; i<4; ++i) + if (!mIngredients[i]->isUserString("ToolTipType")) + { + add = mIngredients[i]; + break; + } if (add != NULL) { @@ -346,14 +297,9 @@ namespace MWGui { std::vector<MWWorld::Ptr> ignore; // don't show ingredients that are currently selected in the "available ingredients" box. - if (mIngredient1->isUserString("ToolTipType")) - ignore.push_back(*mIngredient1->getUserData<MWWorld::Ptr>()); - if (mIngredient2->isUserString("ToolTipType")) - ignore.push_back(*mIngredient2->getUserData<MWWorld::Ptr>()); - if (mIngredient3->isUserString("ToolTipType")) - ignore.push_back(*mIngredient3->getUserData<MWWorld::Ptr>()); - if (mIngredient4->isUserString("ToolTipType")) - ignore.push_back(*mIngredient4->getUserData<MWWorld::Ptr>()); + for (int i=0; i<4; ++i) + if (mIngredients[i]->isUserString("ToolTipType")) + ignore.push_back(*mIngredients[i]->getUserData<MWWorld::Ptr>()); return ignore; } @@ -364,15 +310,7 @@ namespace MWGui for (int i=0; i<4; ++i) { - MyGUI::ImageBox* ingredient; - if (i==0) - ingredient = mIngredient1; - else if (i==1) - ingredient = mIngredient2; - else if (i==2) - ingredient = mIngredient3; - else if (i==3) - ingredient = mIngredient4; + MyGUI::ImageBox* ingredient = mIngredients[i]; if (!ingredient->isUserString("ToolTipType")) continue; diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index 5091fb57a8..179cdd174f 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -22,11 +22,6 @@ namespace MWGui MyGUI::Button* mCreateButton; MyGUI::Button* mCancelButton; - MyGUI::ImageBox* mIngredient1; - MyGUI::ImageBox* mIngredient2; - MyGUI::ImageBox* mIngredient3; - MyGUI::ImageBox* mIngredient4; - MyGUI::Widget* mEffectsBox; MyGUI::EditBox* mNameEdit; @@ -51,6 +46,7 @@ namespace MWGui MWMechanics::Alchemy mAlchemy; std::vector<MyGUI::ImageBox *> mApparatus; + std::vector<MyGUI::ImageBox *> mIngredients; }; } From 7ee038fdd7fcb51f901893ae0e6554a2f0cc3dc1 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 3 Oct 2012 12:03:07 +0200 Subject: [PATCH 016/255] fog now distance based instead of depth --- files/materials/objects.shader | 2 +- files/materials/openmw.configuration | 1 - files/materials/terrain.shader | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/files/materials/objects.shader b/files/materials/objects.shader index 45f33774db..525e4ab636 100644 --- a/files/materials/objects.shader +++ b/files/materials/objects.shader @@ -256,7 +256,7 @@ #endif #if FOG - float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w); + float fogValue = shSaturate((length(cameraPos.xyz-worldPos) - fogParams.y) * fogParams.w); #if UNDERWATER // regular fog only if fragment is above water diff --git a/files/materials/openmw.configuration b/files/materials/openmw.configuration index ee97451d39..2f84680f0e 100644 --- a/files/materials/openmw.configuration +++ b/files/materials/openmw.configuration @@ -1,6 +1,5 @@ configuration water_reflection { - fog false shadows false shadows_pssm false mrt_output false diff --git a/files/materials/terrain.shader b/files/materials/terrain.shader index 9183595e34..35ce403307 100644 --- a/files/materials/terrain.shader +++ b/files/materials/terrain.shader @@ -332,7 +332,7 @@ #if FOG - float fogValue = shSaturate((depth - fogParams.y) * fogParams.w); + float fogValue = shSaturate((length(cameraPos.xyz-worldPos) - fogParams.y) * fogParams.w); #if UNDERWATER // regular fog only if fragment is above water From 1c0dd3ccc57ec4f8e5234be8c49d5afab875b362 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 3 Oct 2012 15:06:54 +0200 Subject: [PATCH 017/255] some editing code --- apps/openmw/mwgui/enchantingdialog.cpp | 6 + apps/openmw/mwgui/enchantingdialog.hpp | 4 + apps/openmw/mwgui/spellcreationdialog.cpp | 167 +++++++++++++++++- apps/openmw/mwgui/spellcreationdialog.hpp | 34 +++- apps/openmw/mwgui/widgets.cpp | 135 +++++++------- apps/openmw/mwgui/windowmanagerimp.cpp | 1 + files/mygui/openmw_enchanting_dialog.layout | 25 ++- .../mygui/openmw_spellcreation_dialog.layout | 3 +- 8 files changed, 294 insertions(+), 81 deletions(-) diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index 990d4d06ec..b3e785fd9f 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -8,7 +8,9 @@ namespace MWGui EnchantingDialog::EnchantingDialog(MWBase::WindowManager &parWindowManager) : WindowBase("openmw_enchanting_dialog.layout", parWindowManager) { + getWidget(mCancelButton, "CancelButton"); + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onCancelButtonClicked); } void EnchantingDialog::open() @@ -27,4 +29,8 @@ namespace MWGui mWindowManager.removeGuiMode (GM_Enchanting); } + void EnchantingDialog::onCancelButtonClicked(MyGUI::Widget* sender) + { + mWindowManager.removeGuiMode (GM_Enchanting); + } } diff --git a/apps/openmw/mwgui/enchantingdialog.hpp b/apps/openmw/mwgui/enchantingdialog.hpp index c6f0a72db3..663758b02f 100644 --- a/apps/openmw/mwgui/enchantingdialog.hpp +++ b/apps/openmw/mwgui/enchantingdialog.hpp @@ -19,6 +19,10 @@ namespace MWGui protected: virtual void onReferenceUnavailable(); + + void onCancelButtonClicked(MyGUI::Widget* sender); + + MyGUI::Button* mCancelButton; }; } diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 133a01fe02..c10295ad13 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -15,6 +15,7 @@ #include "tooltips.hpp" #include "widgets.hpp" +#include "class.hpp" namespace { @@ -31,6 +32,7 @@ namespace MWGui EditEffectDialog::EditEffectDialog(MWBase::WindowManager &parWindowManager) : WindowModal("openmw_edit_effect.layout", parWindowManager) + , mEditing(false) { getWidget(mCancelButton, "CancelButton"); getWidget(mOkButton, "OkButton"); @@ -64,7 +66,27 @@ namespace MWGui onRangeButtonClicked(mRangeButton); } - void EditEffectDialog::setEffect (const ESM::MagicEffect *effect) + void EditEffectDialog::newEffect (const ESM::MagicEffect *effect) + { + setMagicEffect(effect); + mEditing = false; + + mDeleteButton->setVisible (false); + } + + void EditEffectDialog::editEffect (ESM::ENAMstruct effect) + { + const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effect.mEffectID); + + setMagicEffect(magicEffect); + + mEffect = effect; + mEditing = true; + + mDeleteButton->setVisible (true); + } + + void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect) { std::string icon = effect->mIcon; icon[icon.size()-3] = 'd'; @@ -75,6 +97,8 @@ namespace MWGui mEffectImage->setImageTexture (icon); mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}"); + + mEffect.mEffectID = effect->mIndex; } void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender) @@ -94,12 +118,19 @@ namespace MWGui void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender) { + setVisible(false); + eventEffectRemoved(mEffect); } void EditEffectDialog::onOkButtonClicked (MyGUI::Widget* sender) { setVisible(false); + + if (mEditing) + eventEffectModified(mEffect); + else + eventEffectAdded(mEffect); } void EditEffectDialog::onCancelButtonClicked (MyGUI::Widget* sender) @@ -107,6 +138,16 @@ namespace MWGui setVisible(false); } + void EditEffectDialog::setSkill (int skill) + { + mEffect.mSkill = skill; + } + + void EditEffectDialog::setAttribute (int attribute) + { + mEffect.mAttribute = attribute; + } + // ------------------------------------------------------------------------------------------------ SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) @@ -130,6 +171,10 @@ namespace MWGui mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onAvailableEffectClicked); + + mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectAdded); + mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectModified); + mAddEffectDialog.eventEffectRemoved += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectRemoved); } @@ -205,15 +250,131 @@ namespace MWGui } + void SpellCreationDialog::onSelectAttribute () + { + mAddEffectDialog.setVisible(true); + mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId()); + mWindowManager.removeDialog (mSelectAttributeDialog); + mSelectAttributeDialog = 0; + } + + void SpellCreationDialog::onSelectSkill () + { + mAddEffectDialog.setVisible(true); + mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId ()); + mWindowManager.removeDialog (mSelectSkillDialog); + mSelectSkillDialog = 0; + } + + void SpellCreationDialog::onAttributeOrSkillCancel () + { + if (mSelectSkillDialog) + mWindowManager.removeDialog (mSelectSkillDialog); + if (mSelectAttributeDialog) + mWindowManager.removeDialog (mSelectAttributeDialog); + + mSelectSkillDialog = 0; + mSelectAttributeDialog = 0; + } + void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender) { short effectId = *sender->getUserData<short>(); const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); + mAddEffectDialog.newEffect (effect); - mAddEffectDialog.setVisible(true); - mAddEffectDialog.setEffect (effect); + if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill) + { + delete mSelectSkillDialog; + mSelectSkillDialog = new SelectSkillDialog(mWindowManager); + mSelectSkillDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel); + mSelectSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectSkill); + mSelectSkillDialog->setVisible (true); + } + else if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute) + { + delete mSelectAttributeDialog; + mSelectAttributeDialog = new SelectAttributeDialog(mWindowManager); + mSelectAttributeDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel); + mSelectAttributeDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectAttribute); + mSelectAttributeDialog->setVisible (true); + } + else + { + mAddEffectDialog.setVisible(true); + } } + void SpellCreationDialog::onEffectModified (ESM::ENAMstruct effect) + { + mEffects[mSelectedEffect] = effect; + + updateEffectsView(); + } + + void SpellCreationDialog::onEffectRemoved (ESM::ENAMstruct effect) + { + mEffects.erase(mEffects.begin() + mSelectedEffect); + updateEffectsView(); + } + + void SpellCreationDialog::updateEffectsView () + { + MyGUI::EnumeratorWidgetPtr oldWidgets = mUsedEffectsView->getEnumerator (); + MyGUI::Gui::getInstance ().destroyWidgets (oldWidgets); + + MyGUI::IntSize size(0,0); + + int i = 0; + for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) + { + Widgets::SpellEffectParams params; + params.mEffectID = it->mEffectID; + params.mSkill = it->mSkill; + params.mAttribute = it->mAttribute; + params.mDuration = it->mDuration; + params.mMagnMin = it->mMagnMin; + params.mMagnMax = it->mMagnMax; + params.mRange = it->mRange; + + MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); + button->setUserData(i); + button->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onEditEffect); + button->setNeedMouseFocus (true); + + Widgets::MWSpellEffectPtr effect = button->createWidget<Widgets::MWSpellEffect>("MW_EffectImage", MyGUI::IntCoord(0,0,0,24), MyGUI::Align::Default); + + effect->setNeedMouseFocus (false); + effect->setWindowManager (&mWindowManager); + effect->setSpellEffect (params); + + effect->setSize(effect->getRequestedWidth (), 24); + button->setSize(effect->getRequestedWidth (), 24); + + size.width = std::max(size.width, effect->getRequestedWidth ()); + size.height += 24; + ++i; + } + + mUsedEffectsView->setCanvasSize(size); + } + + void SpellCreationDialog::onEffectAdded (ESM::ENAMstruct effect) + { + mEffects.push_back(effect); + + updateEffectsView(); + } + + void SpellCreationDialog::onEditEffect (MyGUI::Widget *sender) + { + int id = *sender->getUserData<int>(); + + mSelectedEffect = id; + + mAddEffectDialog.editEffect (mEffects[id]); + mAddEffectDialog.setVisible (true); + } } diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index a2db719a70..73c9404128 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -4,6 +4,7 @@ #include "window_base.hpp" #include "referenceinterface.hpp" #include "list.hpp" +#include "widgets.hpp" namespace MWGui { @@ -18,7 +19,17 @@ namespace MWGui virtual void open(); - void setEffect (const ESM::MagicEffect* effect); + void setSkill(int skill); + void setAttribute(int attribute); + + void newEffect (const ESM::MagicEffect* effect); + void editEffect (ESM::ENAMstruct effect); + + typedef MyGUI::delegates::CMultiDelegate1<ESM::ENAMstruct> EventHandle_Effect; + + EventHandle_Effect eventEffectAdded; + EventHandle_Effect eventEffectModified; + EventHandle_Effect eventEffectRemoved; protected: MyGUI::Button* mCancelButton; @@ -42,12 +53,16 @@ namespace MWGui MyGUI::ImageBox* mEffectImage; MyGUI::TextBox* mEffectName; + bool mEditing; + protected: void onRangeButtonClicked (MyGUI::Widget* sender); void onDeleteButtonClicked (MyGUI::Widget* sender); void onOkButtonClicked (MyGUI::Widget* sender); void onCancelButtonClicked (MyGUI::Widget* sender); + void setMagicEffect(const ESM::MagicEffect* effect); + protected: ESM::ENAMstruct mEffect; }; @@ -68,6 +83,17 @@ namespace MWGui void onBuyButtonClicked (MyGUI::Widget* sender); void onAvailableEffectClicked (MyGUI::Widget* sender); + void onAttributeOrSkillCancel(); + void onSelectAttribute(); + void onSelectSkill(); + + void onEffectAdded(ESM::ENAMstruct effect); + void onEffectModified(ESM::ENAMstruct effect); + void onEffectRemoved(ESM::ENAMstruct effect); + + void updateEffectsView(); + + void onEditEffect(MyGUI::Widget* sender); MyGUI::EditBox* mNameEdit; MyGUI::TextBox* mMagickaCost; @@ -78,11 +104,17 @@ namespace MWGui MyGUI::Button* mCancelButton; MyGUI::TextBox* mPriceLabel; + int mSelectedEffect; + EditEffectDialog mAddEffectDialog; SelectAttributeDialog* mSelectAttributeDialog; SelectSkillDialog* mSelectSkillDialog; + Widgets::MWEffectList* mUsedEffectsList; + + std::vector<ESM::ENAMstruct> mEffects; + }; } diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 62e65be358..d6a839760d 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -385,82 +385,77 @@ void MWSpellEffect::setSpellEffect(const SpellEffectParams& params) void MWSpellEffect::updateWidgets() { - if (!mWindowManager) - return; - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); - if (!magicEffect) - return; - if (mTextWidget) + + assert(magicEffect); + assert(mWindowManager); + + std::string pt = mWindowManager->getGameSettingString("spoint", ""); + std::string pts = mWindowManager->getGameSettingString("spoints", ""); + std::string to = " " + mWindowManager->getGameSettingString("sTo", "") + " "; + std::string sec = " " + mWindowManager->getGameSettingString("ssecond", ""); + std::string secs = " " + mWindowManager->getGameSettingString("sseconds", ""); + + std::string effectIDStr = ESM::MagicEffect::effectIdToString(mEffectParams.mEffectID); + std::string spellLine = mWindowManager->getGameSettingString(effectIDStr, ""); + + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) { - std::string pt = mWindowManager->getGameSettingString("spoint", ""); - std::string pts = mWindowManager->getGameSettingString("spoints", ""); - std::string to = " " + mWindowManager->getGameSettingString("sTo", "") + " "; - std::string sec = " " + mWindowManager->getGameSettingString("ssecond", ""); - std::string secs = " " + mWindowManager->getGameSettingString("sseconds", ""); - - std::string effectIDStr = ESM::MagicEffect::effectIdToString(mEffectParams.mEffectID); - std::string spellLine = mWindowManager->getGameSettingString(effectIDStr, ""); - if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetSkill) - { - spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[mEffectParams.mSkill], ""); - } - if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) - { - static const char *attributes[8] = { - "sAttributeStrength", - "sAttributeIntelligence", - "sAttributeWillpower", - "sAttributeAgility", - "sAttributeSpeed", - "sAttributeEndurance", - "sAttributePersonality", - "sAttributeLuck" - }; - spellLine += " " + mWindowManager->getGameSettingString(attributes[mEffectParams.mAttribute], ""); - } - - if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) - { - if (mEffectParams.mMagnMin == mEffectParams.mMagnMax) - spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + " " + ((mEffectParams.mMagnMin == 1) ? pt : pts); - else - { - spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax) + " " + pts; - } - } - - // constant effects have no duration and no target - if (!mEffectParams.mIsConstant) - { - if (mEffectParams.mDuration >= 0 && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) - { - spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs); - } - - // potions have no target - if (!mEffectParams.mNoTarget) - { - std::string on = mWindowManager->getGameSettingString("sonword", ""); - if (mEffectParams.mRange == ESM::RT_Self) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); - else if (mEffectParams.mRange == ESM::RT_Touch) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); - else if (mEffectParams.mRange == ESM::RT_Target) - spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); - } - } - - static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(spellLine); - mRequestedWidth = mTextWidget->getTextSize().width + 24; + spellLine += " " + mWindowManager->getGameSettingString(ESM::Skill::sSkillNameIds[mEffectParams.mSkill], ""); } - if (mImageWidget) + if (magicEffect->mData.mFlags & ESM::MagicEffect::TargetAttribute) { - std::string path = std::string("icons\\") + magicEffect->mIcon; - fixTexturePath(path); - mImageWidget->setImageTexture(path); + static const char *attributes[8] = { + "sAttributeStrength", + "sAttributeIntelligence", + "sAttributeWillpower", + "sAttributeAgility", + "sAttributeSpeed", + "sAttributeEndurance", + "sAttributePersonality", + "sAttributeLuck" + }; + spellLine += " " + mWindowManager->getGameSettingString(attributes[mEffectParams.mAttribute], ""); } + + if ((mEffectParams.mMagnMin >= 0 || mEffectParams.mMagnMax >= 0) && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) + { + if (mEffectParams.mMagnMin == mEffectParams.mMagnMax) + spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + " " + ((mEffectParams.mMagnMin == 1) ? pt : pts); + else + { + spellLine += " " + boost::lexical_cast<std::string>(mEffectParams.mMagnMin) + to + boost::lexical_cast<std::string>(mEffectParams.mMagnMax) + " " + pts; + } + } + + // constant effects have no duration and no target + if (!mEffectParams.mIsConstant) + { + if (mEffectParams.mDuration >= 0 && !(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) + { + spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs); + } + + // potions have no target + if (!mEffectParams.mNoTarget) + { + std::string on = mWindowManager->getGameSettingString("sonword", ""); + if (mEffectParams.mRange == ESM::RT_Self) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeSelf", ""); + else if (mEffectParams.mRange == ESM::RT_Touch) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTouch", ""); + else if (mEffectParams.mRange == ESM::RT_Target) + spellLine += " " + on + " " + mWindowManager->getGameSettingString("sRangeTarget", ""); + } + } + + static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(spellLine); + mRequestedWidth = mTextWidget->getTextSize().width + 24; + + std::string path = std::string("icons\\") + magicEffect->mIcon; + fixTexturePath(path); + mImageWidget->setImageTexture(path); } MWSpellEffect::~MWSpellEffect() diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index a043fc6b41..906bb2ca7e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -578,6 +578,7 @@ void WindowManager::onFrame (float frameDuration) mTradeWindow->checkReferenceAvailable(); mSpellBuyingWindow->checkReferenceAvailable(); mSpellCreationDialog->checkReferenceAvailable(); + mEnchantingDialog->checkReferenceAvailable(); mContainerWindow->checkReferenceAvailable(); mConsole->checkReferenceAvailable(); } diff --git a/files/mygui/openmw_enchanting_dialog.layout b/files/mygui/openmw_enchanting_dialog.layout index ea8156056e..e3c8a8b18d 100644 --- a/files/mygui/openmw_enchanting_dialog.layout +++ b/files/mygui/openmw_enchanting_dialog.layout @@ -19,13 +19,26 @@ </Widget> <!-- Item --> - <Widget type="AutoSizedTextBox" skin="NormalText" position="12 48 0 24"> - <Property key="Caption" value="#{sItem}"/> + + <Widget type="HBox" position="12 48 400 59"> + <Property key="Spacing" value="8"/> + + <Widget type="AutoSizedTextBox" skin="NormalText"> + <Property key="Caption" value="#{sItem}"/> + </Widget> + <Widget type="Button" skin="MW_Box" position="0 0 60 59" name="ItemBox"/> + + <Widget type="Widget" position="0 0 8 0"/> + + <Widget type="AutoSizedTextBox" skin="NormalText"> + <Property key="Caption" value="#{sSoulGem}"/> + </Widget> + <Widget type="Button" skin="MW_Box" position="0 0 60 59" name="SoulBox"/> + </Widget> - - <Widget type="TextBox" skin="NormalText" position="280 0 300 24"> + <Widget type="TextBox" skin="NormalText" position="320 0 300 24"> <Property key="Caption" value="#{sEnchantmentMenu3}:"/> </Widget> <Widget type="TextBox" skin="SandText" position="280 0 258 24" name="Enchantment"> @@ -34,7 +47,7 @@ </Widget> - <Widget type="TextBox" skin="NormalText" position="280 24 300 24"> + <Widget type="TextBox" skin="NormalText" position="320 24 300 24"> <Property key="Caption" value="#{sCastCost}:"/> </Widget> <Widget type="TextBox" skin="SandText" position="280 24 258 24" name="CastCost"> @@ -43,7 +56,7 @@ </Widget> - <Widget type="TextBox" skin="NormalText" position="280 48 300 24"> + <Widget type="TextBox" skin="NormalText" position="320 48 300 24"> <Property key="Caption" value="#{sCharges}"/> </Widget> <Widget type="TextBox" skin="SandText" position="280 48 258 24" name="Charge"> diff --git a/files/mygui/openmw_spellcreation_dialog.layout b/files/mygui/openmw_spellcreation_dialog.layout index 2013fece8c..4992243620 100644 --- a/files/mygui/openmw_spellcreation_dialog.layout +++ b/files/mygui/openmw_spellcreation_dialog.layout @@ -48,7 +48,8 @@ <Property key="Caption" value="#{sEffects}"/> </Widget> <Widget type="Widget" skin="MW_Box" position="226 76 316 269"> - <Widget type="ScrollView" skin="MW_ScrollView" position="4 4 308 261" name="UsedEffects"> + <Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 308 261" name="UsedEffects"> + <Property key="CanvasAlign" value="Left Top"/> </Widget> </Widget> From 025e820703344ea3cd7a57cc278d4fc2e42f1586 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 3 Oct 2012 15:36:10 +0200 Subject: [PATCH 018/255] abstracted code and use it in enchanting window as well --- apps/openmw/mwgui/enchantingdialog.cpp | 7 ++ apps/openmw/mwgui/enchantingdialog.hpp | 3 +- apps/openmw/mwgui/spellcreationdialog.cpp | 92 ++++++++++++--------- apps/openmw/mwgui/spellcreationdialog.hpp | 63 ++++++++------ files/mygui/openmw_enchanting_dialog.layout | 3 +- 5 files changed, 105 insertions(+), 63 deletions(-) diff --git a/apps/openmw/mwgui/enchantingdialog.cpp b/apps/openmw/mwgui/enchantingdialog.cpp index b3e785fd9f..3bd67ade63 100644 --- a/apps/openmw/mwgui/enchantingdialog.cpp +++ b/apps/openmw/mwgui/enchantingdialog.cpp @@ -7,8 +7,13 @@ namespace MWGui EnchantingDialog::EnchantingDialog(MWBase::WindowManager &parWindowManager) : WindowBase("openmw_enchanting_dialog.layout", parWindowManager) + , EffectEditorBase(parWindowManager) { getWidget(mCancelButton, "CancelButton"); + getWidget(mAvailableEffectsList, "AvailableEffects"); + getWidget(mUsedEffectsView, "UsedEffects"); + + setWidgets(mAvailableEffectsList, mUsedEffectsView); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EnchantingDialog::onCancelButtonClicked); } @@ -21,6 +26,8 @@ namespace MWGui void EnchantingDialog::startEnchanting (MWWorld::Ptr actor) { mPtr = actor; + + startEditing (); } void EnchantingDialog::onReferenceUnavailable () diff --git a/apps/openmw/mwgui/enchantingdialog.hpp b/apps/openmw/mwgui/enchantingdialog.hpp index 663758b02f..0415c9d8df 100644 --- a/apps/openmw/mwgui/enchantingdialog.hpp +++ b/apps/openmw/mwgui/enchantingdialog.hpp @@ -3,13 +3,14 @@ #include "window_base.hpp" #include "referenceinterface.hpp" +#include "spellcreationdialog.hpp" #include "../mwbase/windowmanager.hpp" namespace MWGui { - class EnchantingDialog : public WindowBase, public ReferenceInterface + class EnchantingDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase { public: EnchantingDialog(MWBase::WindowManager& parWindowManager); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index c10295ad13..4e1c334dbb 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -152,9 +152,7 @@ namespace MWGui SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) : WindowBase("openmw_spellcreation_dialog.layout", parWindowManager) - , mAddEffectDialog(parWindowManager) - , mSelectAttributeDialog(NULL) - , mSelectSkillDialog(NULL) + , EffectEditorBase(parWindowManager) { getWidget(mNameEdit, "NameEdit"); getWidget(mMagickaCost, "MagickaCost"); @@ -165,18 +163,28 @@ namespace MWGui getWidget(mBuyButton, "BuyButton"); getWidget(mCancelButton, "CancelButton"); - mAddEffectDialog.setVisible(false); - mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onCancelButtonClicked); mBuyButton->eventMouseButtonClick += MyGUI::newDelegate(this, &SpellCreationDialog::onBuyButtonClicked); - mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onAvailableEffectClicked); - - mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectAdded); - mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectModified); - mAddEffectDialog.eventEffectRemoved += MyGUI::newDelegate(this, &SpellCreationDialog::onEffectRemoved); + setWidgets(mAvailableEffectsList, mUsedEffectsView); } + void SpellCreationDialog::startSpellMaking (MWWorld::Ptr actor) + { + mPtr = actor; + + startEditing(); + } + + void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender) + { + mWindowManager.removeGuiMode (MWGui::GM_SpellCreation); + } + + void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender) + { + + } void SpellCreationDialog::open() { @@ -189,10 +197,23 @@ namespace MWGui mWindowManager.removeGuiMode (GM_SpellCreation); } - void SpellCreationDialog::startSpellMaking (MWWorld::Ptr actor) - { - mPtr = actor; + // ------------------------------------------------------------------------------------------------ + + EffectEditorBase::EffectEditorBase(MWBase::WindowManager& parWindowManager) + : mAddEffectDialog(parWindowManager) + , mSelectAttributeDialog(NULL) + , mSelectSkillDialog(NULL) + { + mAddEffectDialog.eventEffectAdded += MyGUI::newDelegate(this, &EffectEditorBase::onEffectAdded); + mAddEffectDialog.eventEffectModified += MyGUI::newDelegate(this, &EffectEditorBase::onEffectModified); + mAddEffectDialog.eventEffectRemoved += MyGUI::newDelegate(this, &EffectEditorBase::onEffectRemoved); + + mAddEffectDialog.setVisible (false); + } + + void EffectEditorBase::startEditing () + { // get the list of magic effects that are known to the player MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); @@ -237,47 +258,44 @@ namespace MWGui ToolTips::createMagicEffectToolTip (w, *it); } - } - void SpellCreationDialog::onCancelButtonClicked (MyGUI::Widget* sender) + void EffectEditorBase::setWidgets (Widgets::MWList *availableEffectsList, MyGUI::ScrollView *usedEffectsView) { - mWindowManager.removeGuiMode (MWGui::GM_SpellCreation); + mAvailableEffectsList = availableEffectsList; + mUsedEffectsView = usedEffectsView; + + mAvailableEffectsList->eventWidgetSelected += MyGUI::newDelegate(this, &EffectEditorBase::onAvailableEffectClicked); } - void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender) - { - - } - - void SpellCreationDialog::onSelectAttribute () + void EffectEditorBase::onSelectAttribute () { mAddEffectDialog.setVisible(true); mAddEffectDialog.setAttribute (mSelectAttributeDialog->getAttributeId()); - mWindowManager.removeDialog (mSelectAttributeDialog); + MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog); mSelectAttributeDialog = 0; } - void SpellCreationDialog::onSelectSkill () + void EffectEditorBase::onSelectSkill () { mAddEffectDialog.setVisible(true); mAddEffectDialog.setSkill (mSelectSkillDialog->getSkillId ()); - mWindowManager.removeDialog (mSelectSkillDialog); + MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog); mSelectSkillDialog = 0; } - void SpellCreationDialog::onAttributeOrSkillCancel () + void EffectEditorBase::onAttributeOrSkillCancel () { if (mSelectSkillDialog) - mWindowManager.removeDialog (mSelectSkillDialog); + MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectSkillDialog); if (mSelectAttributeDialog) - mWindowManager.removeDialog (mSelectAttributeDialog); + MWBase::Environment::get().getWindowManager ()->removeDialog (mSelectAttributeDialog); mSelectSkillDialog = 0; mSelectAttributeDialog = 0; } - void SpellCreationDialog::onAvailableEffectClicked (MyGUI::Widget* sender) + void EffectEditorBase::onAvailableEffectClicked (MyGUI::Widget* sender) { short effectId = *sender->getUserData<short>(); @@ -288,7 +306,7 @@ namespace MWGui if (effect->mData.mFlags & ESM::MagicEffect::TargetSkill) { delete mSelectSkillDialog; - mSelectSkillDialog = new SelectSkillDialog(mWindowManager); + mSelectSkillDialog = new SelectSkillDialog(*MWBase::Environment::get().getWindowManager ()); mSelectSkillDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel); mSelectSkillDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectSkill); mSelectSkillDialog->setVisible (true); @@ -296,7 +314,7 @@ namespace MWGui else if (effect->mData.mFlags & ESM::MagicEffect::TargetAttribute) { delete mSelectAttributeDialog; - mSelectAttributeDialog = new SelectAttributeDialog(mWindowManager); + mSelectAttributeDialog = new SelectAttributeDialog(*MWBase::Environment::get().getWindowManager ()); mSelectAttributeDialog->eventCancel += MyGUI::newDelegate(this, &SpellCreationDialog::onAttributeOrSkillCancel); mSelectAttributeDialog->eventItemSelected += MyGUI::newDelegate(this, &SpellCreationDialog::onSelectAttribute); mSelectAttributeDialog->setVisible (true); @@ -307,20 +325,20 @@ namespace MWGui } } - void SpellCreationDialog::onEffectModified (ESM::ENAMstruct effect) + void EffectEditorBase::onEffectModified (ESM::ENAMstruct effect) { mEffects[mSelectedEffect] = effect; updateEffectsView(); } - void SpellCreationDialog::onEffectRemoved (ESM::ENAMstruct effect) + void EffectEditorBase::onEffectRemoved (ESM::ENAMstruct effect) { mEffects.erase(mEffects.begin() + mSelectedEffect); updateEffectsView(); } - void SpellCreationDialog::updateEffectsView () + void EffectEditorBase::updateEffectsView () { MyGUI::EnumeratorWidgetPtr oldWidgets = mUsedEffectsView->getEnumerator (); MyGUI::Gui::getInstance ().destroyWidgets (oldWidgets); @@ -347,7 +365,7 @@ namespace MWGui Widgets::MWSpellEffectPtr effect = button->createWidget<Widgets::MWSpellEffect>("MW_EffectImage", MyGUI::IntCoord(0,0,0,24), MyGUI::Align::Default); effect->setNeedMouseFocus (false); - effect->setWindowManager (&mWindowManager); + effect->setWindowManager (MWBase::Environment::get().getWindowManager ()); effect->setSpellEffect (params); effect->setSize(effect->getRequestedWidth (), 24); @@ -361,14 +379,14 @@ namespace MWGui mUsedEffectsView->setCanvasSize(size); } - void SpellCreationDialog::onEffectAdded (ESM::ENAMstruct effect) + void EffectEditorBase::onEffectAdded (ESM::ENAMstruct effect) { mEffects.push_back(effect); updateEffectsView(); } - void SpellCreationDialog::onEditEffect (MyGUI::Widget *sender) + void EffectEditorBase::onEditEffect (MyGUI::Widget *sender) { int id = *sender->getUserData<int>(); diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index 73c9404128..c5fffeb636 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -67,7 +67,45 @@ namespace MWGui ESM::ENAMstruct mEffect; }; - class SpellCreationDialog : public WindowBase, public ReferenceInterface + + class EffectEditorBase + { + public: + EffectEditorBase(MWBase::WindowManager& parWindowManager); + + + protected: + Widgets::MWList* mAvailableEffectsList; + MyGUI::ScrollView* mUsedEffectsView; + + EditEffectDialog mAddEffectDialog; + SelectAttributeDialog* mSelectAttributeDialog; + SelectSkillDialog* mSelectSkillDialog; + + int mSelectedEffect; + + std::vector<ESM::ENAMstruct> mEffects; + + void onEffectAdded(ESM::ENAMstruct effect); + void onEffectModified(ESM::ENAMstruct effect); + void onEffectRemoved(ESM::ENAMstruct effect); + + void onAvailableEffectClicked (MyGUI::Widget* sender); + + void onAttributeOrSkillCancel(); + void onSelectAttribute(); + void onSelectSkill(); + + void onEditEffect(MyGUI::Widget* sender); + + void updateEffectsView(); + + void startEditing(); + void setWidgets (Widgets::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView); + + }; + + class SpellCreationDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase { public: SpellCreationDialog(MWBase::WindowManager& parWindowManager); @@ -81,40 +119,17 @@ namespace MWGui void onCancelButtonClicked (MyGUI::Widget* sender); void onBuyButtonClicked (MyGUI::Widget* sender); - void onAvailableEffectClicked (MyGUI::Widget* sender); - void onAttributeOrSkillCancel(); - void onSelectAttribute(); - void onSelectSkill(); - - void onEffectAdded(ESM::ENAMstruct effect); - void onEffectModified(ESM::ENAMstruct effect); - void onEffectRemoved(ESM::ENAMstruct effect); - - void updateEffectsView(); - - void onEditEffect(MyGUI::Widget* sender); MyGUI::EditBox* mNameEdit; MyGUI::TextBox* mMagickaCost; MyGUI::TextBox* mSuccessChance; - Widgets::MWList* mAvailableEffectsList; - MyGUI::ScrollView* mUsedEffectsView; MyGUI::Button* mBuyButton; MyGUI::Button* mCancelButton; MyGUI::TextBox* mPriceLabel; - int mSelectedEffect; - - EditEffectDialog mAddEffectDialog; - - SelectAttributeDialog* mSelectAttributeDialog; - SelectSkillDialog* mSelectSkillDialog; - Widgets::MWEffectList* mUsedEffectsList; - std::vector<ESM::ENAMstruct> mEffects; - }; } diff --git a/files/mygui/openmw_enchanting_dialog.layout b/files/mygui/openmw_enchanting_dialog.layout index e3c8a8b18d..a19c569256 100644 --- a/files/mygui/openmw_enchanting_dialog.layout +++ b/files/mygui/openmw_enchanting_dialog.layout @@ -77,7 +77,8 @@ <Property key="Caption" value="#{sEffects}"/> </Widget> <Widget type="Widget" skin="MW_Box" position="226 176 316 169"> - <Widget type="ScrollView" skin="MW_ScrollView" position="4 4 308 161" name="UsedEffects"> + <Widget type="ScrollView" skin="MW_ScrollViewH" position="4 4 308 161" name="UsedEffects"> + <Property key="CanvasAlign" value="Left Top"/> </Widget> </Widget> From 85d9357e3ae71a04493e87113c0805a5b7794287 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Sat, 6 Oct 2012 17:52:46 +0200 Subject: [PATCH 019/255] Travel GUI --- apps/openmw/mwgui/tradewindow.cpp | 2 +- apps/openmw/mwgui/tradewindow.hpp | 2 +- apps/openmw/mwgui/travelwindow.cpp | 14 +++++++------- apps/openmw/mwgui/travelwindow.hpp | 4 +--- apps/openmw/mwgui/windowmanagerimp.cpp | 1 + files/mygui/CMakeLists.txt | 1 + 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 74cae380b3..fc4220fc34 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -16,7 +16,7 @@ namespace MWGui { TradeWindow::TradeWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_trade_window.layout", parWindowManager) - , ReferenceInterface(NULL) // no drag&drop + , ContainerBase(NULL) // no drag&drop , mCurrentBalance(0) { MyGUI::ScrollView* itemView; diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 7ca3a97b47..4ec55045c5 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -20,7 +20,7 @@ namespace MWGui namespace MWGui { - class TradeWindow : public ReferenceInterface, public WindowBase + class TradeWindow : public ContainerBase, public WindowBase { public: TradeWindow(MWBase::WindowManager& parWindowManager); diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index f561a2c99a..674517ace5 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -23,8 +23,7 @@ namespace MWGui const int TravelWindow::sLineHeight = 18; TravelWindow::TravelWindow(MWBase::WindowManager& parWindowManager) : - WindowBase("openmw_spell_buying_window.layout", parWindowManager) - , ContainerBase(NULL) // no drag&drop + WindowBase("openmw_travel_window.layout", parWindowManager) , mCurrentY(0) , mLastPos(0) { @@ -33,8 +32,8 @@ namespace MWGui getWidget(mCancelButton, "CancelButton"); getWidget(mPlayerGold, "PlayerGold"); getWidget(mSelect, "Select"); - getWidget(mDestinations, "Spells"); - getWidget(mDestinationsView, "SpellsView"); + getWidget(mDestinations, "Travel"); + getWidget(mDestinationsView, "DestinationsView"); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onCancelButtonClicked); @@ -61,8 +60,8 @@ namespace MWGui toAdd->setCaptionWithReplacing(travelId+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); - toAdd->setUserString("ToolTipType", "Spell"); - toAdd->setUserString("Spell", travelId); + //toAdd->setUserString("ToolTipType", "Spell"); + toAdd->setUserString("Destination", travelId); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick); mDestinationsWidgetMap.insert(std::make_pair (toAdd, travelId)); } @@ -111,12 +110,13 @@ namespace MWGui } updateLabels(); - mPtr.get<ESM::NPC>()->base->mTransport[0]. + //mPtr.get<ESM::NPC>()->base->mTransport[0]. mDestinationsView->setCanvasSize (MyGUI::IntSize(mDestinationsView->getWidth(), std::max(mDestinationsView->getHeight(), mCurrentY))); } void TravelWindow::onTravelButtonClick(MyGUI::Widget* _sender) { + std::cout << "traveling to:" << _sender->getUserString("Destination"); /*int price = *_sender->getUserData<int>(); if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) diff --git a/apps/openmw/mwgui/travelwindow.hpp b/apps/openmw/mwgui/travelwindow.hpp index 07a516ce80..66360b05bc 100644 --- a/apps/openmw/mwgui/travelwindow.hpp +++ b/apps/openmw/mwgui/travelwindow.hpp @@ -20,7 +20,7 @@ namespace MWGui namespace MWGui { - class TravelWindow : public ContainerBase, public WindowBase + class TravelWindow : public ReferenceInterface, public WindowBase { public: TravelWindow(MWBase::WindowManager& parWindowManager); @@ -35,8 +35,6 @@ namespace MWGui MyGUI::ScrollView* mDestinationsView; - MWWorld::Ptr mActor; - std::map<MyGUI::Widget*, std::string> mDestinationsWidgetMap; void onCancelButtonClicked(MyGUI::Widget* _sender); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 5f76e76cf5..7054b6ba8b 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -376,6 +376,7 @@ void WindowManager::updateVisible() break; case GM_Travel: mTravelWindow->setVisible(true); + break; case GM_SpellCreation: mSpellCreationDialog->setVisible(true); break; diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index a33d59ef6c..2135df3489 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -78,6 +78,7 @@ set(MYGUI_FILES openmw_spellcreation_dialog.layout openmw_edit_effect.layout openmw_enchanting_dialog.layout + openmw_travel_window.layout smallbars.png VeraMono.ttf markers.png From 1f4de03613841da56b28d265516626a4d01756fb Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Sat, 6 Oct 2012 22:33:10 +0200 Subject: [PATCH 020/255] oooups --- files/mygui/openmw_travel_window.layout | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 files/mygui/openmw_travel_window.layout diff --git a/files/mygui/openmw_travel_window.layout b/files/mygui/openmw_travel_window.layout new file mode 100644 index 0000000000..07a6daf489 --- /dev/null +++ b/files/mygui/openmw_travel_window.layout @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<MyGUI type="Layout"> + <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 450 300" name="_Main"> + <Property key="Visible" value="false"/> + + + <Widget type="TextBox" skin="SandText" position="8 10 24 24" name="Select" align="Right Top"> + <Property key="TextAlign" value="Right"/> + <Property key="Caption" value="#{sTravelServiceTitle}"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="0 0 24 24" name="Travel" align="Right Top"> + <Property key="TextAlign" value="Right"/> + <Property key="Caption" value="#D8C09A#{sTravel}"/> + </Widget> + + + <Widget type="Widget" skin="MW_Box" position="6 31 430 225" align="ALIGN_LEFT ALIGN_STRETCH"> + <Widget type="ScrollView" skin="MW_ScrollView" position="4 4 422 217" align="ALIGN_LEFT ALIGN_TOP ALIGN_STRETCH" name="DestinationsView"> + <Property key="CanvasAlign" value="Left"/> + </Widget> + </Widget> + + + <Widget type="TextBox" skin="SandText" position="8 255 24 24" name="PlayerGold" align="Right Top"> + <Property key="TextAlign" value="Right"/> + </Widget> + <Widget type="AutoSizedButton" skin="MW_Button" position="375 260 60 24" name="CancelButton" align="Right Top"> + <Property key="ExpandDirection" value="Left"/> + <Property key="Caption" value="#{sOK}"/> + </Widget> + + </Widget> + +</MyGUI> \ No newline at end of file From 5a611b66d76669b1d564601fc568d071d1f3af5c Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Mon, 8 Oct 2012 11:14:22 +0200 Subject: [PATCH 021/255] traveling. --- apps/openmw/mwgui/travelwindow.cpp | 38 ++++++++++++++++++++---------- apps/openmw/mwgui/travelwindow.hpp | 2 +- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 674517ace5..7414b148a7 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -47,7 +47,7 @@ namespace MWGui mSelect->getHeight()); } - void TravelWindow::addDestination(const std::string& travelId) + void TravelWindow::addDestination(const std::string& travelId,ESM::Position pos,bool interior) { //std::cout << "travel to" << travelId; /*const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); @@ -56,12 +56,17 @@ namespace MWGui MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); mCurrentY += sLineHeight; /// \todo price adjustment depending on merchantile skill - toAdd->setUserData(price); + std::ostringstream oss; + oss << price; + toAdd->setUserString("price",oss.str()); + if(interior) toAdd->setUserString("interior","y"); + else toAdd->setUserString("interior","n"); toAdd->setCaptionWithReplacing(travelId+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); //toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("Destination", travelId); + toAdd->setUserData(pos); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick); mDestinationsWidgetMap.insert(std::make_pair (toAdd, travelId)); } @@ -102,11 +107,12 @@ namespace MWGui for(int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) { std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName; + bool interior = true; int x,y; MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0], mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y); - if(cellname == "") cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->name; - addDestination(cellname); + if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->name; interior= false;} + addDestination(cellname,mPtr.get<ESM::NPC>()->base->mTransport[i].mPos,interior); } updateLabels(); @@ -117,19 +123,25 @@ namespace MWGui void TravelWindow::onTravelButtonClick(MyGUI::Widget* _sender) { std::cout << "traveling to:" << _sender->getUserString("Destination"); - /*int price = *_sender->getUserData<int>(); + std::istringstream iss(_sender->getUserString("price")); + int price; + iss >> price; if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); - MWMechanics::Spells& spells = stats.getSpells(); - spells.add (mSpellsWidgetMap.find(_sender)->second); - mWindowManager.getTradeWindow()->addOrRemoveGold(-price); - startSpellBuying(mPtr); - - MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); - }*/ + ESM::Position pos = *_sender->getUserData<ESM::Position>(); + std::string cellname = _sender->getUserString("Destination"); + int x,y; + bool interior = _sender->getUserString("interior") == "y"; + MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y); + MWWorld::CellStore* cell; + if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname); + else cell = MWBase::Environment::get().getWorld()->getExterior(x,y); + MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]); + mWindowManager.removeGuiMode(GM_Travel); + mWindowManager.removeGuiMode(GM_Dialogue); + } } void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender) diff --git a/apps/openmw/mwgui/travelwindow.hpp b/apps/openmw/mwgui/travelwindow.hpp index 66360b05bc..cc3d6a31f7 100644 --- a/apps/openmw/mwgui/travelwindow.hpp +++ b/apps/openmw/mwgui/travelwindow.hpp @@ -40,7 +40,7 @@ namespace MWGui void onCancelButtonClicked(MyGUI::Widget* _sender); void onTravelButtonClick(MyGUI::Widget* _sender); void onMouseWheel(MyGUI::Widget* _sender, int _rel); - void addDestination(const std::string& destinationID); + void addDestination(const std::string& destinationID,ESM::Position pos,bool interior); void clearDestinations(); int mLastPos,mCurrentY; From 27a3487d78499876ee0e91449c1f91b7330c8470 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Mon, 8 Oct 2012 15:51:36 +0200 Subject: [PATCH 022/255] right prices --- apps/openmw/mwgui/travelwindow.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 7414b148a7..c2eb33c6cd 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -56,11 +56,23 @@ namespace MWGui MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); mCurrentY += sLineHeight; /// \todo price adjustment depending on merchantile skill + if(interior) + { + toAdd->setUserString("interior","y"); + price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat(); + } + else + { + toAdd->setUserString("interior","n"); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + ESM::Position PlayerPos = player.getRefData().getPosition(); + float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); + price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); + } std::ostringstream oss; oss << price; toAdd->setUserString("price",oss.str()); - if(interior) toAdd->setUserString("interior","y"); - else toAdd->setUserString("interior","n"); + toAdd->setCaptionWithReplacing(travelId+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); From 57f3b50dc8fe93cf13bfa7ab0b0465bd88450815 Mon Sep 17 00:00:00 2001 From: cfcohen <cfcohen@verizon.net> Date: Tue, 9 Oct 2012 01:33:47 -0400 Subject: [PATCH 023/255] Add more detail to ESMTool record dumping. --- apps/esmtool/esmtool.cpp | 32 +- apps/esmtool/record.cpp | 625 ++++++++++++++++++++++++++++++++++++--- apps/esmtool/record.hpp | 6 +- 3 files changed, 618 insertions(+), 45 deletions(-) diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index 88709f58b1..944bc7d8c9 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -57,6 +57,8 @@ struct Arguments std::string encoding; std::string filename; std::string outname; + + std::vector<std::string> types; ESMData data; ESM::ESMReader reader; @@ -71,6 +73,8 @@ bool parseOptions (int argc, char** argv, Arguments &info) ("help,h", "print help message.") ("version,v", "print version information and quit.") ("raw,r", "Show an unformattet list of all records and subrecords.") + ("type,t", bpo::value< std::vector<std::string> >(), + "Show only records of this type.") ("quiet,q", "Supress all record information. Useful for speed tests.") ("loadcells,C", "Browse through contents of all cells.") @@ -122,6 +126,9 @@ bool parseOptions (int argc, char** argv, Arguments &info) return false; } + if (variables.count("type") > 0) + info.types = variables["type"].as< std::vector<std::string> >(); + info.mode = variables["mode"].as<std::string>(); if (!(info.mode == "dump" || info.mode == "clone" || info.mode == "comp")) { @@ -306,14 +313,23 @@ int load(Arguments& info) uint32_t flags; esm.getRecHeader(flags); + // Is the user interested in this record type? + bool interested = true; + if (info.types.size() > 0) + { + std::vector<std::string>::iterator match; + match = std::find(info.types.begin(), info.types.end(), + n.toString()); + if (match == info.types.end()) interested = false; + } + std::string id = esm.getHNOString("NAME"); - if(!quiet) + if(!quiet && interested) std::cout << "\nRecord: " << n.toString() << " '" << id << "'\n"; - EsmTool::RecordBase *record = - EsmTool::RecordBase::create(n.val); + EsmTool::RecordBase *record = EsmTool::RecordBase::create(n); if (record == 0) { if (std::find(skipped.begin(), skipped.end(), n.val) == skipped.end()) @@ -326,18 +342,16 @@ int load(Arguments& info) if (quiet) break; std::cout << " Skipping\n"; } else { - if (record->getType() == ESM::REC_GMST) { + if (record->getType().val == ESM::REC_GMST) { // preset id for GameSetting record record->cast<ESM::GameSetting>()->get().mId = id; } record->setId(id); record->setFlags((int) flags); record->load(esm); - if (!quiet) { - record->print(); - } + if (!quiet && interested) record->print(); - if (record->getType() == ESM::REC_CELL && loadCells) { + if (record->getType().val == ESM::REC_CELL && loadCells) { loadCell(record->cast<ESM::Cell>()->get(), esm, info); } @@ -434,7 +448,7 @@ int clone(Arguments& info) { EsmTool::RecordBase *record = *it; - name.val = record->getType(); + name.val = record->getType().val; esm.startRecord(name.toString(), record->getFlags()); diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index 9609e52420..38615b240c 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -1,15 +1,64 @@ #include "record.hpp" #include <iostream> +#include <boost/format.hpp> + +void printAIPackage(ESM::AIPackage p) +{ + if (p.mType == ESM::AI_Wander) + { + std::cout << " AIType Wander:" << std::endl; + std::cout << " Distance: " << p.mWander.mDistance << std::endl; + std::cout << " Duration: " << p.mWander.mDuration << std::endl; + std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl; + if (p.mWander.mUnk != 1) + std::cout << " Unknown: " << (int)p.mWander.mUnk << std::endl; + + std::cout << " Idle: "; + for (int i = 0; i != 8; i++) + std::cout << (int)p.mWander.mIdle[i] << " "; + std::cout << std::endl; + } + else if (p.mType == ESM::AI_Travel) + { + std::cout << " AIType Travel:" << std::endl; + std::cout << " Travel Coordinates: (" << p.mTravel.mX << "," + << p.mTravel.mY << "," << p.mTravel.mZ << ")" << std::endl; + std::cout << " Travel Unknown: " << (int)p.mTravel.mUnk << std::endl; + } + else if (p.mType == ESM::AI_Follow || p.mType == ESM::AI_Escort) + { + if (p.mType == ESM::AI_Follow) std::cout << " AIType Follow:" << std::endl; + else std::cout << " AIType Escort:" << std::endl; + + std::cout << " Follow Coordinates: (" << p.mTarget.mX << "," + << p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl; + std::cout << " Duration: " << p.mTarget.mDuration << std::endl; + std::cout << " Target ID: " << p.mTarget.mId.toString() << std::endl; + std::cout << " Unknown: " << (int)p.mTarget.mUnk << std::endl; + } + else if (p.mType == ESM::AI_Activate) + { + std::cout << " AIType Activate:" << std::endl; + std::cout << " Name: " << p.mActivate.mName.toString() << std::endl; + std::cout << " Activate Unknown: " << (int)p.mActivate.mUnk << std::endl; + } + else { + std::cout << " BadPackage: " << boost::format("0x%08x") % p.mType << std::endl; + } + + if (p.mCellName != "") + std::cout << " Cell Name: " << p.mCellName << std::endl; +} namespace EsmTool { RecordBase * -RecordBase::create(int type) +RecordBase::create(ESM::NAME type) { RecordBase *record = 0; - switch (type) { + switch (type.val) { case ESM::REC_ACTI: { record = new EsmTool::Record<ESM::Activator>; @@ -233,7 +282,7 @@ template<> void Record<ESM::Activator>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Script: " << mData.mScript << std::endl; } @@ -241,38 +290,75 @@ template<> void Record<ESM::Potion>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " AutoCalc: " << mData.mData.mAutoCalc << std::endl; + // mEffects missing } template<> void Record<ESM::Armor>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; - std::cout << " Script: " << mData.mScript << std::endl; - std::cout << " Enchantment: " << mData.mEnchant << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + if (mData.mEnchant != "") + std::cout << " Enchantment: " << mData.mEnchant << std::endl; std::cout << " Type: " << mData.mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " Health: " << mData.mData.mHealth << std::endl; + std::cout << " Armor: " << mData.mData.mArmor << std::endl; + std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; + // mParts missing } template<> void Record<ESM::Apparatus>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " Quality: " << mData.mData.mQuality << std::endl; } template<> void Record<ESM::BodyPart>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Type: " << (int)mData.mData.mType << std::endl; + std::cout << " Flags: " << (int)mData.mData.mFlags << std::endl; + std::cout << " Part: " << (int)mData.mData.mPart << std::endl; + std::cout << " Vampire: " << (int)mData.mData.mVampire << std::endl; } template<> void Record<ESM::Book>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + if (mData.mEnchant != "") + std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " IsScroll: " << mData.mData.mIsScroll << std::endl; + std::cout << " SkillID: " << mData.mData.mSkillID << std::endl; + std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; + // mText missing } template<> @@ -281,13 +367,38 @@ void Record<ESM::BirthSign>::print() std::cout << " Name: " << mData.mName << std::endl; std::cout << " Texture: " << mData.mTexture << std::endl; std::cout << " Description: " << mData.mDescription << std::endl; + std::vector<std::string>::iterator pit; + for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); pit++) + std::cout << " Power: " << *pit << std::endl; } template<> void Record<ESM::Cell>::print() { - std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Region: " << mData.mRegion << std::endl; + // None of the cells have names... + if (mData.mName != "") + std::cout << " Name: " << mData.mName << std::endl; + if (mData.mRegion != "") + std::cout << " Region: " << mData.mRegion << std::endl; + std::cout << " Flags: " << (int)mData.mData.mFlags << std::endl; + + std::cout << " Coordinates: " << " (" << mData.getGridX() << "," + << mData.getGridY() << ")" << std::endl; + + if (mData.mData.mFlags & ESM::Cell::Interior && + !(mData.mData.mFlags & ESM::Cell::QuasiEx)) + { + std::cout << " Ambient Light Color: " << mData.mAmbi.mAmbient << std::endl; + std::cout << " Sunlight Color: " << mData.mAmbi.mSunlight << std::endl; + std::cout << " Fog Color: " << mData.mAmbi.mFog << std::endl; + std::cout << " Fog Density: " << mData.mAmbi.mFogDensity << std::endl; + std::cout << " Water Level: " << mData.mWater << std::endl; + } + else + std::cout << " Map Color: " << boost::format("0x%08X") % mData.mMapColor << std::endl; + std::cout << " Water Level Int: " << mData.mWaterInt << std::endl; + std::cout << " NAM0: " << mData.mNAM0 << std::endl; + } template<> @@ -295,37 +406,120 @@ void Record<ESM::Class>::print() { std::cout << " Name: " << mData.mName << std::endl; std::cout << " Description: " << mData.mDescription << std::endl; + std::cout << " Playable: " << mData.mData.mIsPlayable << std::endl; + std::cout << " AutoCalc: " << mData.mData.mCalc << std::endl; + std::cout << " Attribute1: " << mData.mData.mAttribute[0] << std::endl; + std::cout << " Attribute2: " << mData.mData.mAttribute[1] << std::endl; + std::cout << " Specialization: " << mData.mData.mSpecialization << std::endl; + for (int i = 0; i != 5; i++) + std::cout << " Major Skill: " << mData.mData.mSkills[i][0] << std::endl; + for (int i = 0; i != 5; i++) + std::cout << " Minor Skill: " << mData.mData.mSkills[i][1] << std::endl; } template<> void Record<ESM::Clothing>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + if (mData.mEnchant != "") + std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; + // mEnchant also in CTDTstruct? } template<> void Record<ESM::Container>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Weight: " << mData.mWeight << std::endl; + // mInventory missing } template<> void Record<ESM::Creature>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Original: " << mData.mOriginal << std::endl; + std::cout << " Scale: " << mData.mScale << std::endl; + + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Level: " << mData.mData.mLevel << std::endl; + + std::cout << " Attributes:" << std::endl; + std::cout << " Strength: " << mData.mData.mStrength << std::endl; + std::cout << " Intelligence: " << mData.mData.mIntelligence << std::endl; + std::cout << " Willpower: " << mData.mData.mWillpower << std::endl; + std::cout << " Agility: " << mData.mData.mAgility << std::endl; + std::cout << " Speed: " << mData.mData.mSpeed << std::endl; + std::cout << " Endurance: " << mData.mData.mEndurance << std::endl; + std::cout << " Personality: " << mData.mData.mPersonality << std::endl; + std::cout << " Luck: " << mData.mData.mLuck << std::endl; + + std::cout << " Health: " << mData.mData.mHealth << std::endl; + std::cout << " Magicka: " << mData.mData.mMana << std::endl; + std::cout << " Fatigue: " << mData.mData.mFatigue << std::endl; + std::cout << " Soul: " << mData.mData.mSoul << std::endl; + std::cout << " Combat: " << mData.mData.mCombat << std::endl; + std::cout << " Magic: " << mData.mData.mMagic << std::endl; + std::cout << " Stealth: " << mData.mData.mStealth << std::endl; + std::cout << " Attack1: " << mData.mData.mAttack[0] + << "-" << mData.mData.mAttack[1] << std::endl; + std::cout << " Attack2: " << mData.mData.mAttack[2] + << "-" << mData.mData.mAttack[3] << std::endl; + std::cout << " Attack3: " << mData.mData.mAttack[4] + << "-" << mData.mData.mAttack[5] << std::endl; + std::cout << " Gold: " << mData.mData.mGold << std::endl; + + std::vector<ESM::ContItem>::iterator cit; + for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + << " Item: " << cit->mItem.toString() << std::endl; + + std::vector<std::string>::iterator sit; + for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) + std::cout << " Spell: " << *sit << std::endl; + + std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; + std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl; + std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl; + std::cout << " AI Flee:" << (int)mData.mAiData.mFlee << std::endl; + std::cout << " AI Alarm:" << (int)mData.mAiData.mAlarm << std::endl; + std::cout << " AI U1:" << (int)mData.mAiData.mU1 << std::endl; + std::cout << " AI U2:" << (int)mData.mAiData.mU2 << std::endl; + std::cout << " AI U3:" << (int)mData.mAiData.mU3 << std::endl; + std::cout << " AI U4:" << (int)mData.mAiData.mU4 << std::endl; + std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl; + + std::vector<ESM::AIPackage>::iterator pit; + for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++) + printAIPackage(*pit); } template<> void Record<ESM::Dialogue>::print() { - // nothing to print + std::cout << " Type: " << (int)mData.mType << std::endl; + // mInfo missing } template<> void Record<ESM::Door>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Mesh: " << mData.mModel << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Script: " << mData.mScript << std::endl; std::cout << " OpenSound: " << mData.mOpenSound << std::endl; std::cout << " CloseSound: " << mData.mCloseSound << std::endl; @@ -334,22 +528,51 @@ void Record<ESM::Door>::print() template<> void Record<ESM::Enchantment>::print() { - // nothing to print + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Cost: " << mData.mData.mCost << std::endl; + std::cout << " Charge: " << mData.mData.mCharge << std::endl; + std::cout << " AutoCalc: " << mData.mData.mAutocalc << std::endl; + // mEffects missing } template<> void Record<ESM::Faction>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Attr1: " << mData.mData.mAttribute1 << std::endl; - std::cout << " Attr2: " << mData.mData.mAttribute2 << std::endl; std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl; + if (mData.mData.mUnknown != -1) + std::cout << " Unknown: " << mData.mData.mUnknown << std::endl; + std::cout << " Attribute1: " << mData.mData.mAttribute1 << std::endl; + std::cout << " Attribute2: " << mData.mData.mAttribute2 << std::endl; + for (int i = 0; i != 6; i++) + if (mData.mData.mSkillID[i] != -1) + std::cout << " Skill: " << mData.mData.mSkillID[i] << std::endl; + for (int i = 0; i != 10; i++) + if (mData.mRanks[i] != "") + { + std::cout << " Rank: " << mData.mRanks[i] << std::endl; + std::cout << " Attribute1 Requirement: " + << mData.mData.mRankData[i].mAttribute1 << std::endl; + std::cout << " Attribute2 Requirement: " + << mData.mData.mRankData[i].mAttribute2 << std::endl; + std::cout << " One Skill at Level: " + << mData.mData.mRankData[i].mSkill1 << std::endl; + std::cout << " Two Skills at Level: " + << mData.mData.mRankData[i].mSkill2 << std::endl; + std::cout << " Faction Reaction: " + << mData.mData.mRankData[i].mFactReaction << std::endl; + } + std::vector<ESM::Faction::Reaction>::iterator rit; + for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); rit++) + std::cout << " Reaction: " << rit->mReaction << " = " << rit->mFaction << std::endl; } template<> void Record<ESM::Global>::print() { - // nothing to print + // nothing to print (well, nothing that's correct anyway) + std::cout << " Type: " << mData.mType << std::endl; + std::cout << " Value: " << mData.mValue << std::endl; } template<> @@ -380,67 +603,130 @@ void Record<ESM::DialInfo>::print() { std::cout << " Id: " << mData.mId << std::endl; std::cout << " Text: " << mData.mResponse << std::endl; + // Lots missing, more coming } template<> void Record<ESM::Ingredient>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; + for (int i = 0; i !=4; i++) + { + // A value of -1 means no effect + if (mData.mData.mEffectID[i] == -1) continue; + std::cout << " Effect: " << mData.mData.mEffectID[i] << std::endl; + std::cout << " Skill: " << mData.mData.mSkills[i] << std::endl; + std::cout << " Attribute: " << mData.mData.mAttributes[i] << std::endl; + } } template<> void Record<ESM::Land>::print() { - std::cout << " Coords: [" << mData.mX << "," << mData.mY << "]" << std::endl; + std::cout << " Coordinates: (" << mData.mX << "," << mData.mY << ")" << std::endl; + // Lots missing, more coming } template<> void Record<ESM::CreatureLevList>::print() { + std::cout << " Chance for None: " << (int)mData.mChanceNone << std::endl; + std::cout << " Flags: " << mData.mFlags << std::endl; std::cout << " Number of items: " << mData.mList.size() << std::endl; + std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; + for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) + std::cout << " Creature: Level: " << iit->mLevel + << " Creature: " << iit->mId << std::endl; } template<> void Record<ESM::ItemLevList>::print() { + std::cout << " Chance for None: " << (int)mData.mChanceNone << std::endl; + std::cout << " Flags: " << mData.mFlags << std::endl; std::cout << " Number of items: " << mData.mList.size() << std::endl; + std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; + for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) + std::cout << " Inventory: Count: " << iit->mLevel + << " Item: " << iit->mId << std::endl; } template<> void Record<ESM::Light>::print() { - std::cout << " Name: " << mData.mName << std::endl; + if (mData.mName != "") + std::cout << " Name: " << mData.mName << std::endl; + if (mData.mModel != "") + std::cout << " Model: " << mData.mModel << std::endl; + if (mData.mIcon != "") + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Flags: " << mData.mData.mFlags << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " Sound: " << mData.mSound << std::endl; + std::cout << " Duration: " << mData.mData.mTime << std::endl; + std::cout << " Radius: " << mData.mData.mRadius << std::endl; + std::cout << " Color: " << mData.mData.mColor << std::endl; } template<> void Record<ESM::Tool>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Type: " << mData.mType << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Quality: " << mData.mData.mQuality << std::endl; + std::cout << " Uses: " << mData.mData.mUses << std::endl; } template<> void Record<ESM::Probe>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Type: " << mData.mType << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Quality: " << mData.mData.mQuality << std::endl; + std::cout << " Uses: " << mData.mData.mUses << std::endl; } template<> void Record<ESM::Repair>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Type: " << mData.mType << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; + std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Quality: " << mData.mData.mQuality << std::endl; + std::cout << " Uses: " << mData.mData.mUses << std::endl; } template<> void Record<ESM::LandTexture>::print() { std::cout << " Id: " << mData.mId << std::endl; + std::cout << " Index: " << mData.mIndex << std::endl; std::cout << " Texture: " << mData.mTexture << std::endl; } @@ -448,53 +734,294 @@ template<> void Record<ESM::MagicEffect>::print() { std::cout << " Index: " << mData.mIndex << std::endl; - - const char *text = "Positive"; - if (mData.mData.mFlags & ESM::MagicEffect::Negative) { - text = "Negative"; - } - std::cout << " " << text << std::endl; + std::cout << " Description: " << mData.mDescription << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Particle Texture: " << mData.mParticle << std::endl; + if (mData.mCasting != "") + std::cout << " Casting Static: " << mData.mCasting << std::endl; + if (mData.mCastSound != "") + std::cout << " Casting Sound: " << mData.mCastSound << std::endl; + if (mData.mBolt != "") + std::cout << " Bolt Static: " << mData.mBolt << std::endl; + if (mData.mBoltSound != "") + std::cout << " Bolt Sound: " << mData.mBoltSound << std::endl; + if (mData.mHit != "") + std::cout << " Hit Static: " << mData.mHit << std::endl; + if (mData.mHitSound != "") + std::cout << " Hit Sound: " << mData.mHitSound << std::endl; + if (mData.mArea != "") + std::cout << " Area Static: " << mData.mArea << std::endl; + if (mData.mAreaSound != "") + std::cout << " Area Sound: " << mData.mAreaSound << std::endl; + std::cout << " School: " << mData.mData.mSchool << std::endl; + std::cout << " Base Cost: " << mData.mData.mBaseCost << std::endl; + std::cout << " Speed: " << mData.mData.mSpeed << std::endl; + std::cout << " Size: " << mData.mData.mSize << std::endl; + std::cout << " Size Cap: " << mData.mData.mSizeCap << std::endl; + std::cout << " RGB Color: " << "(" + << mData.mData.mRed << "," + << mData.mData.mGreen << "," + << mData.mData.mGreen << ")" << std::endl; } template<> void Record<ESM::Miscellaneous>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " Is Key: " << mData.mData.mIsKey << std::endl; } template<> void Record<ESM::NPC>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Animation: " << mData.mModel << std::endl; + std::cout << " Hair Model: " << mData.mHair << std::endl; + std::cout << " Head Model: " << mData.mHead << std::endl; std::cout << " Race: " << mData.mRace << std::endl; + std::cout << " Class: " << mData.mClass << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + if (mData.mFaction != "") + std::cout << " Faction: " << mData.mFaction << std::endl; + std::cout << " Flags: " << mData.mFlags << std::endl; + + // Seriously? + if (mData.mNpdt52.mGold == -10) + { + std::cout << " Level: " << mData.mNpdt12.mLevel << std::endl; + std::cout << " Reputation: " << (int)mData.mNpdt12.mReputation << std::endl; + std::cout << " Disposition: " << (int)mData.mNpdt12.mDisposition << std::endl; + std::cout << " Faction: " << (int)mData.mNpdt52.mFactionID << std::endl; + std::cout << " Rank: " << (int)mData.mNpdt12.mRank << std::endl; + std::cout << " Unknown1: " + << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown1) << std::endl; + std::cout << " Unknown2: " + << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown2) << std::endl; + std::cout << " Unknown3: " + << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown3) << std::endl; + std::cout << " Gold: " << (int)mData.mNpdt12.mGold << std::endl; + } + else { + std::cout << " Level: " << mData.mNpdt52.mLevel << std::endl; + std::cout << " Reputation: " << (int)mData.mNpdt52.mReputation << std::endl; + std::cout << " Disposition: " << (int)mData.mNpdt52.mDisposition << std::endl; + std::cout << " Rank: " << (int)mData.mNpdt52.mRank << std::endl; + + std::cout << " Attributes:" << std::endl; + std::cout << " Strength: " << (int)mData.mNpdt52.mStrength << std::endl; + std::cout << " Intelligence: " << (int)mData.mNpdt52.mIntelligence << std::endl; + std::cout << " Willpower: " << (int)mData.mNpdt52.mWillpower << std::endl; + std::cout << " Agility: " << (int)mData.mNpdt52.mAgility << std::endl; + std::cout << " Speed: " << (int)mData.mNpdt52.mSpeed << std::endl; + std::cout << " Endurance: " << (int)mData.mNpdt52.mEndurance << std::endl; + std::cout << " Personality: " << (int)mData.mNpdt52.mPersonality << std::endl; + std::cout << " Luck: " << (int)mData.mNpdt52.mLuck << std::endl; + + std::cout << " Skills:" << std::endl; + for (int i = 0; i != 27; i++) + std::cout << " " << i << " = " + << (int)((unsigned char)mData.mNpdt52.mSkills[i]) << std::endl; + + std::cout << " Health: " << mData.mNpdt52.mHealth << std::endl; + std::cout << " Magicka: " << mData.mNpdt52.mMana << std::endl; + std::cout << " Fatigue: " << mData.mNpdt52.mFatigue << std::endl; + std::cout << " Unknown: " << (int)mData.mNpdt52.mUnknown << std::endl; + std::cout << " Gold: " << mData.mNpdt52.mGold << std::endl; + } + + std::vector<ESM::ContItem>::iterator cit; + for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + << " Item: " << cit->mItem.toString() << std::endl; + + std::vector<std::string>::iterator sit; + for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) + std::cout << " Spell: " << *sit << std::endl; + + std::vector<ESM::NPC::Dest>::iterator dit; + for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); dit++) + { + std::cout << " Destination Position: " + << boost::format("%12.3f") % dit->mPos.pos[0] << "," + << boost::format("%12.3f") % dit->mPos.pos[1] << "," + << boost::format("%12.3f") % dit->mPos.pos[2] << ")" << std::endl; + std::cout << " Destination Rotation: " + << boost::format("%9.6f") % dit->mPos.rot[0] << "," + << boost::format("%9.6f") % dit->mPos.rot[1] << "," + << boost::format("%9.6f") % dit->mPos.rot[2] << ")" << std::endl; + if (dit->mCellName != "") + std::cout << " Destination Cell: " << dit->mCellName << std::endl; + } + + std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; + std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl; + std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl; + std::cout << " AI Flee:" << (int)mData.mAiData.mFlee << std::endl; + std::cout << " AI Alarm:" << (int)mData.mAiData.mAlarm << std::endl; + std::cout << " AI U1:" << (int)mData.mAiData.mU1 << std::endl; + std::cout << " AI U2:" << (int)mData.mAiData.mU2 << std::endl; + std::cout << " AI U3:" << (int)mData.mAiData.mU3 << std::endl; + std::cout << " AI U4:" << (int)mData.mAiData.mU4 << std::endl; + std::cout << " AI Services:" << boost::format("0x%08X") % mData.mAiData.mServices << std::endl; + + std::vector<ESM::AIPackage>::iterator pit; + for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++) + printAIPackage(*pit); } template<> void Record<ESM::Pathgrid>::print() { std::cout << " Cell: " << mData.mCell << std::endl; - std::cout << " Point count: " << mData.mPoints.size() << std::endl; - std::cout << " Edge count: " << mData.mEdges.size() << std::endl; + std::cout << " Coordinates: (" << mData.mData.mX << "," << mData.mData.mY << ")" << std::endl; + std::cout << " Unknown S1: " << mData.mData.mS1 << std::endl; + if ((unsigned int)mData.mData.mS2 != mData.mPoints.size()) + std::cout << " Reported Point Count: " << mData.mData.mS2 << std::endl; + std::cout << " Point Count: " << mData.mPoints.size() << std::endl; + std::cout << " Edge Count: " << mData.mEdges.size() << std::endl; + + int i = 0; + ESM::Pathgrid::PointList::iterator pit; + for (pit = mData.mPoints.begin(); pit != mData.mPoints.end(); pit++) + { + std::cout << " Point[" << i << "]:" << std::endl; + std::cout << " Coordinates: (" << pit->mX << "," + << pit->mY << "," << pit->mZ << ")" << std::endl; + std::cout << " Auto-Generated: " << (int)pit->mAutogenerated << std::endl; + std::cout << " Connections: " << (int)pit->mConnectionNum << std::endl; + std::cout << " Unknown: " << pit->mUnknown << std::endl; + i++; + } + i = 0; + ESM::Pathgrid::EdgeList::iterator eit; + for (eit = mData.mEdges.begin(); eit != mData.mEdges.end(); eit++) + { + std::cout << " Edge[" << i << "]: " << eit->mV0 << " -> " << eit->mV1 << std::endl; + if (eit->mV0 >= mData.mData.mS2 || eit->mV1 >= mData.mData.mS2) + std::cout << " BAD POINT IN EDGE!" << std::endl; + i++; + } } template<> void Record<ESM::Race>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Length: " << mData.mData.mHeight.mMale << "m " << mData.mData.mHeight.mFemale << "f" << std::endl; + std::cout << " Description: " << mData.mDescription << std::endl; + std::cout << " Flags: " << mData.mData.mFlags << std::endl; + + std::cout << " Male:" << std::endl; + std::cout << " Strength: " + << mData.mData.mStrength.mMale << std::endl; + std::cout << " Intelligence: " + << mData.mData.mIntelligence.mMale << std::endl; + std::cout << " Willpower: " + << mData.mData.mWillpower.mMale << std::endl; + std::cout << " Agility: " + << mData.mData.mAgility.mMale << std::endl; + std::cout << " Speed: " + << mData.mData.mSpeed.mMale << std::endl; + std::cout << " Endurance: " + << mData.mData.mEndurance.mMale << std::endl; + std::cout << " Personality: " + << mData.mData.mPersonality.mMale << std::endl; + std::cout << " Luck: " + << mData.mData.mLuck.mMale << std::endl; + std::cout << " Height: " + << mData.mData.mHeight.mMale << std::endl; + std::cout << " Weight: " + << mData.mData.mWeight.mMale << std::endl; + + std::cout << " Female:" << std::endl; + std::cout << " Strength: " + << mData.mData.mStrength.mFemale << std::endl; + std::cout << " Intelligence: " + << mData.mData.mIntelligence.mFemale << std::endl; + std::cout << " Willpower: " + << mData.mData.mWillpower.mFemale << std::endl; + std::cout << " Agility: " + << mData.mData.mAgility.mFemale << std::endl; + std::cout << " Speed: " + << mData.mData.mSpeed.mFemale << std::endl; + std::cout << " Endurance: " + << mData.mData.mEndurance.mFemale << std::endl; + std::cout << " Personality: " + << mData.mData.mPersonality.mFemale << std::endl; + std::cout << " Luck: " + << mData.mData.mLuck.mFemale << std::endl; + std::cout << " Height: " + << mData.mData.mHeight.mFemale << std::endl; + std::cout << " Weight: " + << mData.mData.mWeight.mFemale << std::endl; + + for (int i = 0; i != 7; i++) + // Not all races have 7 skills. + if (mData.mData.mBonus[i].mSkill != -1) + std::cout << " Skill: " << mData.mData.mBonus[i].mSkill + << " = " << mData.mData.mBonus[i].mBonus << std::endl; + + std::vector<std::string>::iterator sit; + for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); sit++) + std::cout << " Power: " << *sit << std::endl; } template<> void Record<ESM::Region>::print() { std::cout << " Name: " << mData.mName << std::endl; + + std::cout << " Weather:" << std::endl; + std::cout << " Clear: " << (int)mData.mData.mClear << std::endl; + std::cout << " Cloudy: " << (int)mData.mData.mCloudy << std::endl; + std::cout << " Foggy: " << (int)mData.mData.mFoggy << std::endl; + std::cout << " Overcast: " << (int)mData.mData.mOvercast << std::endl; + std::cout << " Rain: " << (int)mData.mData.mOvercast << std::endl; + std::cout << " Thunder: " << (int)mData.mData.mThunder << std::endl; + std::cout << " Ash: " << (int)mData.mData.mAsh << std::endl; + std::cout << " Blight: " << (int)mData.mData.mBlight << std::endl; + std::cout << " UnknownA: " << (int)mData.mData.mA << std::endl; + std::cout << " UnknownB: " << (int)mData.mData.mB << std::endl; + std::cout << " Map Color: " << mData.mMapColor << std::endl; + if (mData.mSleepList != "") + std::cout << " Sleep List: " << mData.mSleepList << std::endl; + std::vector<ESM::Region::SoundRef>::iterator sit; + for (sit = mData.mSoundList.begin(); sit != mData.mSoundList.end(); sit++) + std::cout << " Sound: " << (int)sit->mChance << " = " << sit->mSound.toString() << std::endl; } template<> void Record<ESM::Script>::print() { std::cout << " Name: " << mData.mData.mName.toString() << std::endl; + + std::cout << " Num Shorts: " << mData.mData.mNumShorts << std::endl; + std::cout << " Num Longs: " << mData.mData.mNumLongs << std::endl; + std::cout << " Num Floats: " << mData.mData.mNumFloats << std::endl; + std::cout << " Script Data Size: " << mData.mData.mScriptDataSize << std::endl; + std::cout << " Table Size: " << mData.mData.mStringTableSize << std::endl; + + std::cout << " Script: [skipped]" << std::endl; + // Skip until multi-line field is controllable by a command line option. + //std::cout << "-------------------------------------------" << std::endl; + //std::cout << s->scriptText << std::endl; + //std::cout << "-------------------------------------------" << std::endl; + std::vector<std::string>::iterator vit; + for (vit = mData.mVarNames.begin(); vit != mData.mVarNames.end(); vit++) + std::cout << " Variable: " << *vit << std::endl; + + std::cout << " ByteCode: "; + std::vector<char>::iterator cit; + for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); cit++) + std::cout << boost::format("%02X") % (int)(*cit); + std::cout << std::endl; } template<> @@ -519,25 +1046,34 @@ void Record<ESM::SoundGenerator>::print() { std::cout << " Creature: " << mData.mCreature << std::endl; std::cout << " Sound: " << mData.mSound << std::endl; + std::cout << " Type: " << mData.mType << std::endl; } template<> void Record<ESM::Sound>::print() { std::cout << " Sound: " << mData.mSound << std::endl; - std::cout << " Volume: " << mData.mData.mVolume << std::endl; + std::cout << " Volume: " << (int)mData.mData.mVolume << std::endl; + if (mData.mData.mMinRange != 0 && mData.mData.mMaxRange != 0) + std::cout << " Range: " << (int)mData.mData.mMinRange << " - " + << (int)mData.mData.mMaxRange << std::endl; } template<> void Record<ESM::Spell>::print() { std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Cost: " << mData.mData.mCost << std::endl; + // mEffect missing } template<> void Record<ESM::StartScript>::print() { - std::cout << "Start script: " << mData.mScript << std::endl; + std::cout << "Start Script: " << mData.mScript << std::endl; + std::cout << "Start Data: " << mData.mData << std::endl; } template<> @@ -549,11 +1085,34 @@ void Record<ESM::Static>::print() template<> void Record<ESM::Weapon>::print() { - std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Chop: " << mData.mData.mChop[0] << "-" << mData.mData.mChop[1] << std::endl; - std::cout << " Slash: " << mData.mData.mSlash[0] << "-" << mData.mData.mSlash[1] << std::endl; - std::cout << " Thrust: " << mData.mData.mThrust[0] << "-" << mData.mData.mThrust[1] << std::endl; + // No names on VFX bolts + if (mData.mName != "") + std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; + // No icons on VFX bolts or magic bolts + if (mData.mIcon != "") + std::cout << " Icon: " << mData.mIcon << std::endl; + if (mData.mScript != "") + std::cout << " Script: " << mData.mScript << std::endl; + if (mData.mEnchant != "") + std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; + std::cout << " Health: " << mData.mData.mHealth << std::endl; + std::cout << " Speed: " << mData.mData.mSpeed << std::endl; + std::cout << " Reach: " << mData.mData.mReach << std::endl; + std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; + if (mData.mData.mChop[0] != 0 && mData.mData.mChop[1] != 0) + std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-" + << (int)mData.mData.mChop[1] << std::endl; + if (mData.mData.mSlash[0] != 0 && mData.mData.mSlash[1] != 0) + std::cout << " Slash: " << (int)mData.mData.mSlash[0] << "-" + << (int)mData.mData.mSlash[1] << std::endl; + if (mData.mData.mThrust[0] != 0 && mData.mData.mThrust[1] != 0) + std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-" + << (int)mData.mData.mThrust[1] << std::endl; } template<> diff --git a/apps/esmtool/record.hpp b/apps/esmtool/record.hpp index 3cd7f5b54b..e75870ab69 100644 --- a/apps/esmtool/record.hpp +++ b/apps/esmtool/record.hpp @@ -20,7 +20,7 @@ namespace EsmTool protected: std::string mId; int mFlags; - int mType; + ESM::NAME mType; public: RecordBase () {} @@ -42,7 +42,7 @@ namespace EsmTool mFlags = flags; } - int getType() const { + ESM::NAME getType() const { return mType; } @@ -50,7 +50,7 @@ namespace EsmTool virtual void save(ESM::ESMWriter &esm) = 0; virtual void print() = 0; - static RecordBase *create(int type); + static RecordBase *create(ESM::NAME type); // just make it a bit shorter template <class T> From 35d099a63856bc37ce381388f2135066a4460836 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 9 Oct 2012 17:10:25 +0200 Subject: [PATCH 024/255] disabling gcc extensions --- CMakeLists.txt | 2 +- apps/launcher/pluginsview.hpp | 4 ++-- apps/mwiniimporter/importer.cpp | 8 ++++---- apps/openmw/main.cpp | 2 +- apps/openmw/mwbase/soundmanager.hpp | 2 +- apps/openmw/mwmechanics/drawstate.hpp | 2 +- apps/openmw/mwrender/globalmap.cpp | 4 ++-- apps/openmw/mwrender/water.hpp | 2 +- apps/openmw/mwscript/scriptmanagerimp.hpp | 2 +- apps/openmw/mwsound/mpgsnd_decoder.hpp | 2 +- apps/openmw/mwsound/openal_output.hpp | 2 +- apps/openmw/mwsound/soundmanagerimp.hpp | 2 +- components/esm/aipackage.hpp | 2 +- components/esm_store/reclists.hpp | 4 ++-- libs/openengine/bullet/CMotionState.cpp | 2 +- libs/openengine/bullet/physic.cpp | 2 +- 16 files changed, 22 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 614a840c4a..b10562eef2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,7 +306,7 @@ endif() # Compiler settings if (CMAKE_COMPILER_IS_GNUCC) - add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder) + add_definitions (-Wall -Wextra -Wno-unused-parameter -Wno-reorder -std=c++0x -pedantic) # Silence warnings in OGRE headers. Remove once OGRE got fixed! add_definitions (-Wno-ignored-qualifiers) diff --git a/apps/launcher/pluginsview.hpp b/apps/launcher/pluginsview.hpp index b3dfb79ffb..484351e33a 100644 --- a/apps/launcher/pluginsview.hpp +++ b/apps/launcher/pluginsview.hpp @@ -24,6 +24,6 @@ public slots: }; -Q_DECLARE_METATYPE(QVector<QPersistentModelIndex>); +Q_DECLARE_METATYPE(QVector<QPersistentModelIndex>) -#endif \ No newline at end of file +#endif diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index d396df648f..19b69794f2 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -78,7 +78,7 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(std::string filename) { multistrmap::iterator it; if((it = map.find(key)) == map.end()) { - map.insert( std::make_pair<std::string, std::vector<std::string> > (key, std::vector<std::string>() ) ); + map.insert( std::make_pair (key, std::vector<std::string>() ) ); } map[key].push_back(value); } @@ -115,7 +115,7 @@ MwIniImporter::multistrmap MwIniImporter::loadCfgFile(std::string filename) { multistrmap::iterator it; if((it = map.find(key)) == map.end()) { - map.insert( std::make_pair<std::string, std::vector<std::string> > (key, std::vector<std::string>() ) ); + map.insert( std::make_pair (key, std::vector<std::string>() ) ); } map[key].push_back(value); } @@ -152,12 +152,12 @@ void MwIniImporter::mergeFallback(multistrmap &cfg, multistrmap &ini) { } } } -}; +} void MwIniImporter::insertMultistrmap(multistrmap &cfg, std::string key, std::string value) { multistrmap::iterator it = cfg.find(key); if(it == cfg.end()) { - cfg.insert(std::make_pair<std::string, std::vector<std::string> >(key, std::vector<std::string>() )); + cfg.insert(std::make_pair (key, std::vector<std::string>() )); } cfg[key].push_back(value); } diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 5c2ba2f80b..2da52311fd 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -68,7 +68,7 @@ void validate(boost::any &v, std::vector<std::string> const &tokens, FallbackMap if((mapIt = map->mMap.find(key)) == map->mMap.end()) { - map->mMap.insert(std::make_pair<std::string,std::string>(key,value)); + map->mMap.insert(std::make_pair (key,value)); } } } diff --git a/apps/openmw/mwbase/soundmanager.hpp b/apps/openmw/mwbase/soundmanager.hpp index 745832583c..92c177ff30 100644 --- a/apps/openmw/mwbase/soundmanager.hpp +++ b/apps/openmw/mwbase/soundmanager.hpp @@ -37,7 +37,7 @@ namespace MWBase Play_Normal = 0, /* tracked, non-looping, multi-instance, environment */ Play_Loop = 1<<0, /* Sound will continually loop until explicitly stopped */ Play_NoEnv = 1<<1, /* Do not apply environment effects (eg, underwater filters) */ - Play_NoTrack = 1<<2, /* (3D only) Play the sound at the given object's position + Play_NoTrack = 1<<2 /* (3D only) Play the sound at the given object's position * but do not keep it updated (the sound will not move with * the object and will not stop when the object is deleted. */ }; diff --git a/apps/openmw/mwmechanics/drawstate.hpp b/apps/openmw/mwmechanics/drawstate.hpp index 112b6e4f90..5be00505c2 100644 --- a/apps/openmw/mwmechanics/drawstate.hpp +++ b/apps/openmw/mwmechanics/drawstate.hpp @@ -8,7 +8,7 @@ namespace MWMechanics { DrawState_Weapon = 0, DrawState_Spell = 1, - DrawState_Nothing = 2, + DrawState_Nothing = 2 }; } diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index c23fdc1a3b..7a799a2e43 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -53,7 +53,7 @@ namespace MWRender { Ogre::Image image; - Ogre::uchar data[mWidth * mHeight * 3]; + std::vector<Ogre::uchar> data (mWidth * mHeight * 3); for (int x = mMinX; x <= mMaxX; ++x) { @@ -150,7 +150,7 @@ namespace MWRender } } - image.loadDynamicImage (data, mWidth, mHeight, Ogre::PF_B8G8R8); + image.loadDynamicImage (&data[0], mWidth, mHeight, Ogre::PF_B8G8R8); //image.save (mCacheDir + "/GlobalMap.png"); diff --git a/apps/openmw/mwrender/water.hpp b/apps/openmw/mwrender/water.hpp index dcb76533b0..f1e3d7a3be 100644 --- a/apps/openmw/mwrender/water.hpp +++ b/apps/openmw/mwrender/water.hpp @@ -23,7 +23,7 @@ namespace Ogre class Entity; class Vector3; struct RenderTargetEvent; -}; +} namespace MWRender { diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index bacc232b2c..a97310ae5c 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -74,6 +74,6 @@ namespace MWScript ///< Return index of the variable of the given name and type in the given script. Will /// throw an exception, if there is no such script or variable or the type does not match. }; -}; +} #endif diff --git a/apps/openmw/mwsound/mpgsnd_decoder.hpp b/apps/openmw/mwsound/mpgsnd_decoder.hpp index 870773edc5..09082c2f47 100644 --- a/apps/openmw/mwsound/mpgsnd_decoder.hpp +++ b/apps/openmw/mwsound/mpgsnd_decoder.hpp @@ -52,6 +52,6 @@ namespace MWSound #ifndef DEFAULT_DECODER #define DEFAULT_DECODER (::MWSound::MpgSnd_Decoder) #endif -}; +} #endif diff --git a/apps/openmw/mwsound/openal_output.hpp b/apps/openmw/mwsound/openal_output.hpp index 90917c53c7..fecffa5752 100644 --- a/apps/openmw/mwsound/openal_output.hpp +++ b/apps/openmw/mwsound/openal_output.hpp @@ -66,6 +66,6 @@ namespace MWSound #ifndef DEFAULT_OUTPUT #define DEFAULT_OUTPUT (::MWSound::OpenAL_Output) #endif -}; +} #endif diff --git a/apps/openmw/mwsound/soundmanagerimp.hpp b/apps/openmw/mwsound/soundmanagerimp.hpp index f91e291efc..a84aa3b9a7 100644 --- a/apps/openmw/mwsound/soundmanagerimp.hpp +++ b/apps/openmw/mwsound/soundmanagerimp.hpp @@ -26,7 +26,7 @@ namespace MWSound enum Environment { Env_Normal, - Env_Underwater, + Env_Underwater }; class SoundManager : public MWBase::SoundManager diff --git a/components/esm/aipackage.hpp b/components/esm/aipackage.hpp index 3046a6a98f..8e55b68892 100644 --- a/components/esm/aipackage.hpp +++ b/components/esm/aipackage.hpp @@ -60,7 +60,7 @@ namespace ESM AI_Travel = 0x545f4941, AI_Follow = 0x465f4941, AI_Escort = 0x455f4941, - AI_Activate = 0x415f4941, + AI_Activate = 0x415f4941 }; /// \note Used for storaging packages in a single container diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index 24580a79c4..0b265a5666 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -331,7 +331,7 @@ namespace ESMS // Find land for the given coordinates. Return null if no mData. Land *search(int x, int y) const { - LandMap::const_iterator itr = lands.find(std::make_pair<int, int>(x, y)); + LandMap::const_iterator itr = lands.find(std::make_pair (x, y)); if ( itr == lands.end() ) { return NULL; @@ -350,7 +350,7 @@ namespace ESMS land->load(esm); // Store the structure - lands[std::make_pair<int, int>(land->mX, land->mY)] = land; + lands[std::make_pair (land->mX, land->mY)] = land; } }; diff --git a/libs/openengine/bullet/CMotionState.cpp b/libs/openengine/bullet/CMotionState.cpp index dc28d9e5f0..6be615dfb0 100644 --- a/libs/openengine/bullet/CMotionState.cpp +++ b/libs/openengine/bullet/CMotionState.cpp @@ -16,7 +16,7 @@ namespace Physic pEng = eng; tr.setIdentity(); pName = name; - }; + } void CMotionState::getWorldTransform(btTransform &worldTrans) const { diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index b42ffb84c1..4f16a41438 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -626,4 +626,4 @@ namespace Physic shape->Shape->getAabb(trans, min, max); } -}}; +}} From 3fd887c030c4b4e9848356c1d4cb79645f457ee1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 9 Oct 2012 17:11:41 +0200 Subject: [PATCH 025/255] silenced some warnings --- components/esm/esmwriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esm/esmwriter.cpp b/components/esm/esmwriter.cpp index 24658a40b5..c1ae064903 100644 --- a/components/esm/esmwriter.cpp +++ b/components/esm/esmwriter.cpp @@ -138,11 +138,11 @@ void ESMWriter::writeHNString(const std::string& name, const std::string& data) void ESMWriter::writeHNString(const std::string& name, const std::string& data, int size) { - assert(data.size() <= size); + assert(static_cast<int> (data.size()) <= size); startSubRecord(name); writeHString(data); - if (data.size() < size) + if (static_cast<int> (data.size()) < size) { for (int i = data.size(); i < size; ++i) write("\0",1); From d97184cd4d144ca53b3df857f58b9dfcd3d74efc Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 9 Oct 2012 17:48:44 +0200 Subject: [PATCH 026/255] fixing some warnings --- extern/shiny | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/shiny b/extern/shiny index ffd078843c..b9ed0f2f3f 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit ffd078843c11586107024ccbc2493d0ec2df896c +Subproject commit b9ed0f2f3f10915aafd083248a1d6a37293c0db0 From 94f2937c8f87a04807e648c1085444da43d75cc6 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 9 Oct 2012 19:28:10 +0200 Subject: [PATCH 027/255] missed a warning --- extern/shiny | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/shiny b/extern/shiny index b9ed0f2f3f..f17c4ebab0 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit b9ed0f2f3f10915aafd083248a1d6a37293c0db0 +Subproject commit f17c4ebab0e7a1f3bbb25fd9b3dbef2bd742536a From 50e259c060b3666c4d28e919474a3bbea14c922a Mon Sep 17 00:00:00 2001 From: cfcohen <cfcohen@verizon.net> Date: Tue, 9 Oct 2012 19:41:45 -0400 Subject: [PATCH 028/255] Remove tabs as requested. Sorry about that, thought I already had. :-) I updated the help to better document the --type option, although I did not finish reasoning through it's interaction with the new loading framework. I also expanded the print() methods of a few more of the record types to make a more consistent commit. --- apps/esmtool/esmtool.cpp | 29 ++- apps/esmtool/record.cpp | 495 +++++++++++++++++++++++---------------- apps/esmtool/record.hpp | 4 +- 3 files changed, 317 insertions(+), 211 deletions(-) diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index 944bc7d8c9..4f6d9dbfc0 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -13,7 +13,7 @@ #include "record.hpp" -#define ESMTOOL_VERSION 1.1 +#define ESMTOOL_VERSION 1.2 // Create a local alias for brevity namespace bpo = boost::program_options; @@ -72,9 +72,12 @@ bool parseOptions (int argc, char** argv, Arguments &info) desc.add_options() ("help,h", "print help message.") ("version,v", "print version information and quit.") - ("raw,r", "Show an unformattet list of all records and subrecords.") - ("type,t", bpo::value< std::vector<std::string> >(), - "Show only records of this type.") + ("raw,r", "Show an unformatted list of all records and subrecords.") + // The intention is that this option would interact better + // with other modes including clone, dump, and raw. + ("type,t", bpo::value< std::vector<std::string> >(), + "Show only records of this type (four character record code). May " + "be specified multiple times. Only affects dump mode.") ("quiet,q", "Supress all record information. Useful for speed tests.") ("loadcells,C", "Browse through contents of all cells.") @@ -313,15 +316,15 @@ int load(Arguments& info) uint32_t flags; esm.getRecHeader(flags); - // Is the user interested in this record type? - bool interested = true; - if (info.types.size() > 0) - { - std::vector<std::string>::iterator match; - match = std::find(info.types.begin(), info.types.end(), - n.toString()); - if (match == info.types.end()) interested = false; - } + // Is the user interested in this record type? + bool interested = true; + if (info.types.size() > 0) + { + std::vector<std::string>::iterator match; + match = std::find(info.types.begin(), info.types.end(), + n.toString()); + if (match == info.types.end()) interested = false; + } std::string id = esm.getHNOString("NAME"); diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index 38615b240c..c679a1c4df 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -12,18 +12,18 @@ void printAIPackage(ESM::AIPackage p) std::cout << " Duration: " << p.mWander.mDuration << std::endl; std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl; if (p.mWander.mUnk != 1) - std::cout << " Unknown: " << (int)p.mWander.mUnk << std::endl; + std::cout << " Unknown: " << (int)p.mWander.mUnk << std::endl; std::cout << " Idle: "; for (int i = 0; i != 8; i++) - std::cout << (int)p.mWander.mIdle[i] << " "; + std::cout << (int)p.mWander.mIdle[i] << " "; std::cout << std::endl; } else if (p.mType == ESM::AI_Travel) { std::cout << " AIType Travel:" << std::endl; std::cout << " Travel Coordinates: (" << p.mTravel.mX << "," - << p.mTravel.mY << "," << p.mTravel.mZ << ")" << std::endl; + << p.mTravel.mY << "," << p.mTravel.mZ << ")" << std::endl; std::cout << " Travel Unknown: " << (int)p.mTravel.mUnk << std::endl; } else if (p.mType == ESM::AI_Follow || p.mType == ESM::AI_Escort) @@ -32,7 +32,7 @@ void printAIPackage(ESM::AIPackage p) else std::cout << " AIType Escort:" << std::endl; std::cout << " Follow Coordinates: (" << p.mTarget.mX << "," - << p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl; + << p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl; std::cout << " Duration: " << p.mTarget.mDuration << std::endl; std::cout << " Target ID: " << p.mTarget.mId.toString() << std::endl; std::cout << " Unknown: " << (int)p.mTarget.mUnk << std::endl; @@ -51,6 +51,27 @@ void printAIPackage(ESM::AIPackage p) std::cout << " Cell Name: " << p.mCellName << std::endl; } +void printEffectList(ESM::EffectList effects) +{ + int i = 0; + std::vector<ESM::ENAMstruct>::iterator eit; + for (eit = effects.mList.begin(); eit != effects.mList.end(); eit++) + { + std::cout << " Effect[" << i << "]: " << eit->mEffectID << std::endl; + if (eit->mSkill != -1) + std::cout << " Skill: " << (int)eit->mSkill << std::endl; + if (eit->mAttribute != -1) + std::cout << " Attribute: " << (int)eit->mAttribute << std::endl; + std::cout << " Range: " << eit->mRange << std::endl; + // Area is always zero if range type is "Self" + if (eit->mRange != ESM::RT_Self) + std::cout << " Area: " << eit->mArea << std::endl; + std::cout << " Duration: " << eit->mDuration << std::endl; + std::cout << " Magnitude: " << eit->mMagnMin << "-" << eit->mMagnMax << std::endl; + i++; + } +} + namespace EsmTool { RecordBase * @@ -293,11 +314,11 @@ void Record<ESM::Potion>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " AutoCalc: " << mData.mData.mAutoCalc << std::endl; - // mEffects missing + printEffectList(mData.mEffects); } template<> @@ -307,16 +328,23 @@ void Record<ESM::Armor>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") - std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Enchantment: " << mData.mEnchant << std::endl; std::cout << " Type: " << mData.mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Health: " << mData.mData.mHealth << std::endl; std::cout << " Armor: " << mData.mData.mArmor << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; - // mParts missing + std::vector<ESM::PartReference>::iterator pit; + for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++) + { + std::cout << " Body Part: " << (int)(pit->mPart) << std::endl; + std::cout << " Male Name: " << pit->mMale << std::endl; + if (pit->mFemale != "") + std::cout << " Female Name: " << pit->mFemale << std::endl; + } } template<> @@ -350,15 +378,20 @@ void Record<ESM::Book>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") - std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Enchantment: " << mData.mEnchant << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " IsScroll: " << mData.mData.mIsScroll << std::endl; std::cout << " SkillID: " << mData.mData.mSkillID << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; - // mText missing + std::cout << " Text: [skipped]" << std::endl; + // Skip until multi-line fields is controllable by a command line option. + // Mildly problematic because there are no parameter to print() currently. + // std::cout << "-------------------------------------------" << std::endl; + // std::cout << mData.mText << std::endl; + // std::cout << "-------------------------------------------" << std::endl; } template<> @@ -369,7 +402,7 @@ void Record<ESM::BirthSign>::print() std::cout << " Description: " << mData.mDescription << std::endl; std::vector<std::string>::iterator pit; for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); pit++) - std::cout << " Power: " << *pit << std::endl; + std::cout << " Power: " << *pit << std::endl; } template<> @@ -377,25 +410,25 @@ void Record<ESM::Cell>::print() { // None of the cells have names... if (mData.mName != "") - std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Name: " << mData.mName << std::endl; if (mData.mRegion != "") - std::cout << " Region: " << mData.mRegion << std::endl; + std::cout << " Region: " << mData.mRegion << std::endl; std::cout << " Flags: " << (int)mData.mData.mFlags << std::endl; std::cout << " Coordinates: " << " (" << mData.getGridX() << "," - << mData.getGridY() << ")" << std::endl; + << mData.getGridY() << ")" << std::endl; if (mData.mData.mFlags & ESM::Cell::Interior && - !(mData.mData.mFlags & ESM::Cell::QuasiEx)) + !(mData.mData.mFlags & ESM::Cell::QuasiEx)) { - std::cout << " Ambient Light Color: " << mData.mAmbi.mAmbient << std::endl; - std::cout << " Sunlight Color: " << mData.mAmbi.mSunlight << std::endl; - std::cout << " Fog Color: " << mData.mAmbi.mFog << std::endl; - std::cout << " Fog Density: " << mData.mAmbi.mFogDensity << std::endl; - std::cout << " Water Level: " << mData.mWater << std::endl; + std::cout << " Ambient Light Color: " << mData.mAmbi.mAmbient << std::endl; + std::cout << " Sunlight Color: " << mData.mAmbi.mSunlight << std::endl; + std::cout << " Fog Color: " << mData.mAmbi.mFog << std::endl; + std::cout << " Fog Density: " << mData.mAmbi.mFogDensity << std::endl; + std::cout << " Water Level: " << mData.mWater << std::endl; } else - std::cout << " Map Color: " << boost::format("0x%08X") % mData.mMapColor << std::endl; + std::cout << " Map Color: " << boost::format("0x%08X") % mData.mMapColor << std::endl; std::cout << " Water Level Int: " << mData.mWaterInt << std::endl; std::cout << " NAM0: " << mData.mNAM0 << std::endl; @@ -412,9 +445,9 @@ void Record<ESM::Class>::print() std::cout << " Attribute2: " << mData.mData.mAttribute[1] << std::endl; std::cout << " Specialization: " << mData.mData.mSpecialization << std::endl; for (int i = 0; i != 5; i++) - std::cout << " Major Skill: " << mData.mData.mSkills[i][0] << std::endl; + std::cout << " Major Skill: " << mData.mData.mSkills[i][0] << std::endl; for (int i = 0; i != 5; i++) - std::cout << " Minor Skill: " << mData.mData.mSkills[i][1] << std::endl; + std::cout << " Minor Skill: " << mData.mData.mSkills[i][1] << std::endl; } template<> @@ -424,9 +457,9 @@ void Record<ESM::Clothing>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") - std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Enchantment: " << mData.mEnchant << std::endl; std::cout << " Type: " << mData.mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; @@ -439,10 +472,13 @@ void Record<ESM::Container>::print() std::cout << " Name: " << mData.mName << std::endl; std::cout << " Model: " << mData.mModel << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Flags: " << mData.mFlags << std::endl; std::cout << " Weight: " << mData.mWeight << std::endl; - // mInventory missing + std::vector<ESM::ContItem>::iterator cit; + for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + << " Item: " << cit->mItem.toString() << std::endl; } template<> @@ -476,21 +512,21 @@ void Record<ESM::Creature>::print() std::cout << " Magic: " << mData.mData.mMagic << std::endl; std::cout << " Stealth: " << mData.mData.mStealth << std::endl; std::cout << " Attack1: " << mData.mData.mAttack[0] - << "-" << mData.mData.mAttack[1] << std::endl; + << "-" << mData.mData.mAttack[1] << std::endl; std::cout << " Attack2: " << mData.mData.mAttack[2] - << "-" << mData.mData.mAttack[3] << std::endl; + << "-" << mData.mData.mAttack[3] << std::endl; std::cout << " Attack3: " << mData.mData.mAttack[4] - << "-" << mData.mData.mAttack[5] << std::endl; + << "-" << mData.mData.mAttack[5] << std::endl; std::cout << " Gold: " << mData.mData.mGold << std::endl; std::vector<ESM::ContItem>::iterator cit; for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) - std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount - << " Item: " << cit->mItem.toString() << std::endl; + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + << " Item: " << cit->mItem.toString() << std::endl; std::vector<std::string>::iterator sit; for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) - std::cout << " Spell: " << *sit << std::endl; + std::cout << " Spell: " << *sit << std::endl; std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl; @@ -505,14 +541,19 @@ void Record<ESM::Creature>::print() std::vector<ESM::AIPackage>::iterator pit; for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++) - printAIPackage(*pit); + printAIPackage(*pit); } template<> void Record<ESM::Dialogue>::print() { std::cout << " Type: " << (int)mData.mType << std::endl; - // mInfo missing + // Sadly, there are no DialInfos, because the loader dumps as it + // loads, rather than loading and then dumping. :-( Anyone mind if + // I change this? + std::vector<ESM::DialInfo>::iterator iit; + for (iit = mData.mInfo.begin(); iit != mData.mInfo.end(); iit++) + std::cout << "INFO!" << iit->mId << std::endl; } template<> @@ -532,7 +573,7 @@ void Record<ESM::Enchantment>::print() std::cout << " Cost: " << mData.mData.mCost << std::endl; std::cout << " Charge: " << mData.mData.mCharge << std::endl; std::cout << " AutoCalc: " << mData.mData.mAutocalc << std::endl; - // mEffects missing + printEffectList(mData.mEffects); } template<> @@ -541,30 +582,30 @@ void Record<ESM::Faction>::print() std::cout << " Name: " << mData.mName << std::endl; std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl; if (mData.mData.mUnknown != -1) - std::cout << " Unknown: " << mData.mData.mUnknown << std::endl; + std::cout << " Unknown: " << mData.mData.mUnknown << std::endl; std::cout << " Attribute1: " << mData.mData.mAttribute1 << std::endl; std::cout << " Attribute2: " << mData.mData.mAttribute2 << std::endl; for (int i = 0; i != 6; i++) - if (mData.mData.mSkillID[i] != -1) - std::cout << " Skill: " << mData.mData.mSkillID[i] << std::endl; + if (mData.mData.mSkillID[i] != -1) + std::cout << " Skill: " << mData.mData.mSkillID[i] << std::endl; for (int i = 0; i != 10; i++) - if (mData.mRanks[i] != "") - { - std::cout << " Rank: " << mData.mRanks[i] << std::endl; - std::cout << " Attribute1 Requirement: " - << mData.mData.mRankData[i].mAttribute1 << std::endl; - std::cout << " Attribute2 Requirement: " - << mData.mData.mRankData[i].mAttribute2 << std::endl; - std::cout << " One Skill at Level: " - << mData.mData.mRankData[i].mSkill1 << std::endl; - std::cout << " Two Skills at Level: " - << mData.mData.mRankData[i].mSkill2 << std::endl; - std::cout << " Faction Reaction: " - << mData.mData.mRankData[i].mFactReaction << std::endl; - } + if (mData.mRanks[i] != "") + { + std::cout << " Rank: " << mData.mRanks[i] << std::endl; + std::cout << " Attribute1 Requirement: " + << mData.mData.mRankData[i].mAttribute1 << std::endl; + std::cout << " Attribute2 Requirement: " + << mData.mData.mRankData[i].mAttribute2 << std::endl; + std::cout << " One Skill at Level: " + << mData.mData.mRankData[i].mSkill1 << std::endl; + std::cout << " Two Skills at Level: " + << mData.mData.mRankData[i].mSkill2 << std::endl; + std::cout << " Faction Reaction: " + << mData.mData.mRankData[i].mFactReaction << std::endl; + } std::vector<ESM::Faction::Reaction>::iterator rit; for (rit = mData.mReactions.begin(); rit != mData.mReactions.end(); rit++) - std::cout << " Reaction: " << rit->mReaction << " = " << rit->mFaction << std::endl; + std::cout << " Reaction: " << rit->mReaction << " = " << rit->mFaction << std::endl; } template<> @@ -602,8 +643,53 @@ template<> void Record<ESM::DialInfo>::print() { std::cout << " Id: " << mData.mId << std::endl; + if (mData.mPrev != "") + std::cout << " Previous ID: " << mData.mPrev << std::endl; + if (mData.mNext != "") + std::cout << " Next ID: " << mData.mNext << std::endl; std::cout << " Text: " << mData.mResponse << std::endl; - // Lots missing, more coming + if (mData.mActor != "") + std::cout << " Actor: " << mData.mActor << std::endl; + if (mData.mRace != "") + std::cout << " Race: " << mData.mRace << std::endl; + if (mData.mClass != "") + std::cout << " Class: " << mData.mClass << std::endl; + std::cout << " Factionless: " << mData.mFactionLess << std::endl; + if (mData.mNpcFaction != "") + std::cout << " NPC Faction: " << mData.mNpcFaction << std::endl; + if (mData.mData.mRank != -1) + std::cout << " NPC Rank: " << (int)mData.mData.mRank << std::endl; + if (mData.mPcFaction != "") + std::cout << " PC Faction: " << mData.mPcFaction << std::endl; + // CHANGE? non-standard capitalization mPCrank -> mPCRank (mPcRank?) + if (mData.mData.mPCrank != -1) + std::cout << " PC Rank: " << (int)mData.mData.mPCrank << std::endl; + if (mData.mCell != "") + std::cout << " Cell: " << mData.mCell << std::endl; + if (mData.mData.mDisposition > 0) + std::cout << " Disposition: " << mData.mData.mDisposition << std::endl; + if (mData.mData.mGender != ESM::DialInfo::NA) + std::cout << " Gender: " << mData.mData.mGender << std::endl; + if (mData.mSound != "") + std::cout << " Sound File: " << mData.mSound << std::endl; + + if (mData.mResultScript != "") + { + std::cout << " Result Script: [skipped]" << std::endl; + // Skip until multi-line fields is controllable by a command line option. + // Mildly problematic because there are no parameter to print() currently. + // std::cout << "-------------------------------------------" << std::endl; + // std::cout << mData.mResultScript << std::endl; + // std::cout << "-------------------------------------------" << std::endl; + } + + std::cout << " Quest Status: " << mData.mQuestStatus << std::endl; + std::cout << " Unknown1: " << mData.mData.mUnknown1 << std::endl; + std::cout << " Unknown2: " << (int)mData.mData.mUnknown2 << std::endl; + + std::vector<ESM::DialInfo::SelectStruct>::iterator sit; + for (sit = mData.mSelects.begin(); sit != mData.mSelects.end(); sit++) + std::cout << " Select Rule: " << sit->mType << " " << sit->mSelectRule << std::endl; } template<> @@ -613,16 +699,16 @@ void Record<ESM::Ingredient>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; for (int i = 0; i !=4; i++) { - // A value of -1 means no effect - if (mData.mData.mEffectID[i] == -1) continue; - std::cout << " Effect: " << mData.mData.mEffectID[i] << std::endl; - std::cout << " Skill: " << mData.mData.mSkills[i] << std::endl; - std::cout << " Attribute: " << mData.mData.mAttributes[i] << std::endl; + // A value of -1 means no effect + if (mData.mData.mEffectID[i] == -1) continue; + std::cout << " Effect: " << mData.mData.mEffectID[i] << std::endl; + std::cout << " Skill: " << mData.mData.mSkills[i] << std::endl; + std::cout << " Attribute: " << mData.mData.mAttributes[i] << std::endl; } } @@ -630,7 +716,23 @@ template<> void Record<ESM::Land>::print() { std::cout << " Coordinates: (" << mData.mX << "," << mData.mY << ")" << std::endl; - // Lots missing, more coming + std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " HasData: " << mData.mHasData << std::endl; + std::cout << " DataTypes: " << mData.mDataTypes << std::endl; + + // Seems like this should done with reference counting in the + // loader to me. But I'm not really knowledgable about this + // record type yet. --Cory + bool wasLoaded = mData.mDataLoaded; + if (mData.mDataTypes) mData.loadData(mData.mDataTypes); + if (mData.mDataLoaded) + { + std::cout << " Height Offset: " << mData.mLandData->mHeightOffset << std::endl; + // Lots of missing members. + std::cout << " Unknown1: " << mData.mLandData->mUnk1 << std::endl; + std::cout << " Unknown2: " << mData.mLandData->mUnk2 << std::endl; + } + if (!wasLoaded) mData.unloadData(); } template<> @@ -641,8 +743,8 @@ void Record<ESM::CreatureLevList>::print() std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) - std::cout << " Creature: Level: " << iit->mLevel - << " Creature: " << iit->mId << std::endl; + std::cout << " Creature: Level: " << iit->mLevel + << " Creature: " << iit->mId << std::endl; } template<> @@ -653,21 +755,21 @@ void Record<ESM::ItemLevList>::print() std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) - std::cout << " Inventory: Count: " << iit->mLevel - << " Item: " << iit->mId << std::endl; + std::cout << " Inventory: Count: " << iit->mLevel + << " Item: " << iit->mId << std::endl; } template<> void Record<ESM::Light>::print() { if (mData.mName != "") - std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Name: " << mData.mName << std::endl; if (mData.mModel != "") - std::cout << " Model: " << mData.mModel << std::endl; + std::cout << " Model: " << mData.mModel << std::endl; if (mData.mIcon != "") - std::cout << " Icon: " << mData.mIcon << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Flags: " << mData.mData.mFlags << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; @@ -684,7 +786,7 @@ void Record<ESM::Tool>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Type: " << mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; @@ -699,7 +801,7 @@ void Record<ESM::Probe>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Type: " << mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; @@ -714,7 +816,7 @@ void Record<ESM::Repair>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Type: " << mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; @@ -739,30 +841,30 @@ void Record<ESM::MagicEffect>::print() std::cout << " Flags: " << mData.mData.mFlags << std::endl; std::cout << " Particle Texture: " << mData.mParticle << std::endl; if (mData.mCasting != "") - std::cout << " Casting Static: " << mData.mCasting << std::endl; + std::cout << " Casting Static: " << mData.mCasting << std::endl; if (mData.mCastSound != "") - std::cout << " Casting Sound: " << mData.mCastSound << std::endl; + std::cout << " Casting Sound: " << mData.mCastSound << std::endl; if (mData.mBolt != "") - std::cout << " Bolt Static: " << mData.mBolt << std::endl; + std::cout << " Bolt Static: " << mData.mBolt << std::endl; if (mData.mBoltSound != "") - std::cout << " Bolt Sound: " << mData.mBoltSound << std::endl; + std::cout << " Bolt Sound: " << mData.mBoltSound << std::endl; if (mData.mHit != "") - std::cout << " Hit Static: " << mData.mHit << std::endl; + std::cout << " Hit Static: " << mData.mHit << std::endl; if (mData.mHitSound != "") - std::cout << " Hit Sound: " << mData.mHitSound << std::endl; + std::cout << " Hit Sound: " << mData.mHitSound << std::endl; if (mData.mArea != "") - std::cout << " Area Static: " << mData.mArea << std::endl; + std::cout << " Area Static: " << mData.mArea << std::endl; if (mData.mAreaSound != "") - std::cout << " Area Sound: " << mData.mAreaSound << std::endl; + std::cout << " Area Sound: " << mData.mAreaSound << std::endl; std::cout << " School: " << mData.mData.mSchool << std::endl; std::cout << " Base Cost: " << mData.mData.mBaseCost << std::endl; std::cout << " Speed: " << mData.mData.mSpeed << std::endl; std::cout << " Size: " << mData.mData.mSize << std::endl; std::cout << " Size Cap: " << mData.mData.mSizeCap << std::endl; std::cout << " RGB Color: " << "(" - << mData.mData.mRed << "," - << mData.mData.mGreen << "," - << mData.mData.mGreen << ")" << std::endl; + << mData.mData.mRed << "," + << mData.mData.mGreen << "," + << mData.mData.mGreen << ")" << std::endl; } template<> @@ -772,7 +874,7 @@ void Record<ESM::Miscellaneous>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Is Key: " << mData.mData.mIsKey << std::endl; @@ -788,77 +890,77 @@ void Record<ESM::NPC>::print() std::cout << " Race: " << mData.mRace << std::endl; std::cout << " Class: " << mData.mClass << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; if (mData.mFaction != "") - std::cout << " Faction: " << mData.mFaction << std::endl; + std::cout << " Faction: " << mData.mFaction << std::endl; std::cout << " Flags: " << mData.mFlags << std::endl; // Seriously? if (mData.mNpdt52.mGold == -10) { - std::cout << " Level: " << mData.mNpdt12.mLevel << std::endl; - std::cout << " Reputation: " << (int)mData.mNpdt12.mReputation << std::endl; - std::cout << " Disposition: " << (int)mData.mNpdt12.mDisposition << std::endl; - std::cout << " Faction: " << (int)mData.mNpdt52.mFactionID << std::endl; - std::cout << " Rank: " << (int)mData.mNpdt12.mRank << std::endl; - std::cout << " Unknown1: " - << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown1) << std::endl; - std::cout << " Unknown2: " - << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown2) << std::endl; - std::cout << " Unknown3: " - << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown3) << std::endl; - std::cout << " Gold: " << (int)mData.mNpdt12.mGold << std::endl; + std::cout << " Level: " << mData.mNpdt12.mLevel << std::endl; + std::cout << " Reputation: " << (int)mData.mNpdt12.mReputation << std::endl; + std::cout << " Disposition: " << (int)mData.mNpdt12.mDisposition << std::endl; + std::cout << " Faction: " << (int)mData.mNpdt52.mFactionID << std::endl; + std::cout << " Rank: " << (int)mData.mNpdt12.mRank << std::endl; + std::cout << " Unknown1: " + << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown1) << std::endl; + std::cout << " Unknown2: " + << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown2) << std::endl; + std::cout << " Unknown3: " + << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown3) << std::endl; + std::cout << " Gold: " << (int)mData.mNpdt12.mGold << std::endl; } else { - std::cout << " Level: " << mData.mNpdt52.mLevel << std::endl; - std::cout << " Reputation: " << (int)mData.mNpdt52.mReputation << std::endl; - std::cout << " Disposition: " << (int)mData.mNpdt52.mDisposition << std::endl; - std::cout << " Rank: " << (int)mData.mNpdt52.mRank << std::endl; + std::cout << " Level: " << mData.mNpdt52.mLevel << std::endl; + std::cout << " Reputation: " << (int)mData.mNpdt52.mReputation << std::endl; + std::cout << " Disposition: " << (int)mData.mNpdt52.mDisposition << std::endl; + std::cout << " Rank: " << (int)mData.mNpdt52.mRank << std::endl; - std::cout << " Attributes:" << std::endl; - std::cout << " Strength: " << (int)mData.mNpdt52.mStrength << std::endl; - std::cout << " Intelligence: " << (int)mData.mNpdt52.mIntelligence << std::endl; - std::cout << " Willpower: " << (int)mData.mNpdt52.mWillpower << std::endl; - std::cout << " Agility: " << (int)mData.mNpdt52.mAgility << std::endl; - std::cout << " Speed: " << (int)mData.mNpdt52.mSpeed << std::endl; - std::cout << " Endurance: " << (int)mData.mNpdt52.mEndurance << std::endl; - std::cout << " Personality: " << (int)mData.mNpdt52.mPersonality << std::endl; - std::cout << " Luck: " << (int)mData.mNpdt52.mLuck << std::endl; + std::cout << " Attributes:" << std::endl; + std::cout << " Strength: " << (int)mData.mNpdt52.mStrength << std::endl; + std::cout << " Intelligence: " << (int)mData.mNpdt52.mIntelligence << std::endl; + std::cout << " Willpower: " << (int)mData.mNpdt52.mWillpower << std::endl; + std::cout << " Agility: " << (int)mData.mNpdt52.mAgility << std::endl; + std::cout << " Speed: " << (int)mData.mNpdt52.mSpeed << std::endl; + std::cout << " Endurance: " << (int)mData.mNpdt52.mEndurance << std::endl; + std::cout << " Personality: " << (int)mData.mNpdt52.mPersonality << std::endl; + std::cout << " Luck: " << (int)mData.mNpdt52.mLuck << std::endl; - std::cout << " Skills:" << std::endl; - for (int i = 0; i != 27; i++) - std::cout << " " << i << " = " - << (int)((unsigned char)mData.mNpdt52.mSkills[i]) << std::endl; - - std::cout << " Health: " << mData.mNpdt52.mHealth << std::endl; - std::cout << " Magicka: " << mData.mNpdt52.mMana << std::endl; - std::cout << " Fatigue: " << mData.mNpdt52.mFatigue << std::endl; - std::cout << " Unknown: " << (int)mData.mNpdt52.mUnknown << std::endl; - std::cout << " Gold: " << mData.mNpdt52.mGold << std::endl; + std::cout << " Skills:" << std::endl; + for (int i = 0; i != 27; i++) + std::cout << " " << i << " = " + << (int)((unsigned char)mData.mNpdt52.mSkills[i]) << std::endl; + + std::cout << " Health: " << mData.mNpdt52.mHealth << std::endl; + std::cout << " Magicka: " << mData.mNpdt52.mMana << std::endl; + std::cout << " Fatigue: " << mData.mNpdt52.mFatigue << std::endl; + std::cout << " Unknown: " << (int)mData.mNpdt52.mUnknown << std::endl; + std::cout << " Gold: " << mData.mNpdt52.mGold << std::endl; } std::vector<ESM::ContItem>::iterator cit; for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) - std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount - << " Item: " << cit->mItem.toString() << std::endl; + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + << " Item: " << cit->mItem.toString() << std::endl; std::vector<std::string>::iterator sit; for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) - std::cout << " Spell: " << *sit << std::endl; + std::cout << " Spell: " << *sit << std::endl; std::vector<ESM::NPC::Dest>::iterator dit; for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); dit++) { - std::cout << " Destination Position: " - << boost::format("%12.3f") % dit->mPos.pos[0] << "," - << boost::format("%12.3f") % dit->mPos.pos[1] << "," - << boost::format("%12.3f") % dit->mPos.pos[2] << ")" << std::endl; - std::cout << " Destination Rotation: " - << boost::format("%9.6f") % dit->mPos.rot[0] << "," - << boost::format("%9.6f") % dit->mPos.rot[1] << "," - << boost::format("%9.6f") % dit->mPos.rot[2] << ")" << std::endl; - if (dit->mCellName != "") - std::cout << " Destination Cell: " << dit->mCellName << std::endl; + std::cout << " Destination Position: " + << boost::format("%12.3f") % dit->mPos.pos[0] << "," + << boost::format("%12.3f") % dit->mPos.pos[1] << "," + << boost::format("%12.3f") % dit->mPos.pos[2] << ")" << std::endl; + std::cout << " Destination Rotation: " + << boost::format("%9.6f") % dit->mPos.rot[0] << "," + << boost::format("%9.6f") % dit->mPos.rot[1] << "," + << boost::format("%9.6f") % dit->mPos.rot[2] << ")" << std::endl; + if (dit->mCellName != "") + std::cout << " Destination Cell: " << dit->mCellName << std::endl; } std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; @@ -874,7 +976,7 @@ void Record<ESM::NPC>::print() std::vector<ESM::AIPackage>::iterator pit; for (pit = mData.mAiPackage.mList.begin(); pit != mData.mAiPackage.mList.end(); pit++) - printAIPackage(*pit); + printAIPackage(*pit); } template<> @@ -884,7 +986,7 @@ void Record<ESM::Pathgrid>::print() std::cout << " Coordinates: (" << mData.mData.mX << "," << mData.mData.mY << ")" << std::endl; std::cout << " Unknown S1: " << mData.mData.mS1 << std::endl; if ((unsigned int)mData.mData.mS2 != mData.mPoints.size()) - std::cout << " Reported Point Count: " << mData.mData.mS2 << std::endl; + std::cout << " Reported Point Count: " << mData.mData.mS2 << std::endl; std::cout << " Point Count: " << mData.mPoints.size() << std::endl; std::cout << " Edge Count: " << mData.mEdges.size() << std::endl; @@ -892,22 +994,22 @@ void Record<ESM::Pathgrid>::print() ESM::Pathgrid::PointList::iterator pit; for (pit = mData.mPoints.begin(); pit != mData.mPoints.end(); pit++) { - std::cout << " Point[" << i << "]:" << std::endl; - std::cout << " Coordinates: (" << pit->mX << "," - << pit->mY << "," << pit->mZ << ")" << std::endl; - std::cout << " Auto-Generated: " << (int)pit->mAutogenerated << std::endl; - std::cout << " Connections: " << (int)pit->mConnectionNum << std::endl; - std::cout << " Unknown: " << pit->mUnknown << std::endl; - i++; + std::cout << " Point[" << i << "]:" << std::endl; + std::cout << " Coordinates: (" << pit->mX << "," + << pit->mY << "," << pit->mZ << ")" << std::endl; + std::cout << " Auto-Generated: " << (int)pit->mAutogenerated << std::endl; + std::cout << " Connections: " << (int)pit->mConnectionNum << std::endl; + std::cout << " Unknown: " << pit->mUnknown << std::endl; + i++; } i = 0; ESM::Pathgrid::EdgeList::iterator eit; for (eit = mData.mEdges.begin(); eit != mData.mEdges.end(); eit++) { - std::cout << " Edge[" << i << "]: " << eit->mV0 << " -> " << eit->mV1 << std::endl; - if (eit->mV0 >= mData.mData.mS2 || eit->mV1 >= mData.mData.mS2) - std::cout << " BAD POINT IN EDGE!" << std::endl; - i++; + std::cout << " Edge[" << i << "]: " << eit->mV0 << " -> " << eit->mV1 << std::endl; + if (eit->mV0 >= mData.mData.mS2 || eit->mV1 >= mData.mData.mS2) + std::cout << " BAD POINT IN EDGE!" << std::endl; + i++; } } @@ -920,57 +1022,57 @@ void Record<ESM::Race>::print() std::cout << " Male:" << std::endl; std::cout << " Strength: " - << mData.mData.mStrength.mMale << std::endl; + << mData.mData.mStrength.mMale << std::endl; std::cout << " Intelligence: " - << mData.mData.mIntelligence.mMale << std::endl; + << mData.mData.mIntelligence.mMale << std::endl; std::cout << " Willpower: " - << mData.mData.mWillpower.mMale << std::endl; + << mData.mData.mWillpower.mMale << std::endl; std::cout << " Agility: " - << mData.mData.mAgility.mMale << std::endl; + << mData.mData.mAgility.mMale << std::endl; std::cout << " Speed: " - << mData.mData.mSpeed.mMale << std::endl; + << mData.mData.mSpeed.mMale << std::endl; std::cout << " Endurance: " - << mData.mData.mEndurance.mMale << std::endl; + << mData.mData.mEndurance.mMale << std::endl; std::cout << " Personality: " - << mData.mData.mPersonality.mMale << std::endl; + << mData.mData.mPersonality.mMale << std::endl; std::cout << " Luck: " - << mData.mData.mLuck.mMale << std::endl; + << mData.mData.mLuck.mMale << std::endl; std::cout << " Height: " - << mData.mData.mHeight.mMale << std::endl; + << mData.mData.mHeight.mMale << std::endl; std::cout << " Weight: " - << mData.mData.mWeight.mMale << std::endl; + << mData.mData.mWeight.mMale << std::endl; std::cout << " Female:" << std::endl; std::cout << " Strength: " - << mData.mData.mStrength.mFemale << std::endl; + << mData.mData.mStrength.mFemale << std::endl; std::cout << " Intelligence: " - << mData.mData.mIntelligence.mFemale << std::endl; + << mData.mData.mIntelligence.mFemale << std::endl; std::cout << " Willpower: " - << mData.mData.mWillpower.mFemale << std::endl; + << mData.mData.mWillpower.mFemale << std::endl; std::cout << " Agility: " - << mData.mData.mAgility.mFemale << std::endl; + << mData.mData.mAgility.mFemale << std::endl; std::cout << " Speed: " - << mData.mData.mSpeed.mFemale << std::endl; + << mData.mData.mSpeed.mFemale << std::endl; std::cout << " Endurance: " - << mData.mData.mEndurance.mFemale << std::endl; + << mData.mData.mEndurance.mFemale << std::endl; std::cout << " Personality: " - << mData.mData.mPersonality.mFemale << std::endl; + << mData.mData.mPersonality.mFemale << std::endl; std::cout << " Luck: " - << mData.mData.mLuck.mFemale << std::endl; + << mData.mData.mLuck.mFemale << std::endl; std::cout << " Height: " - << mData.mData.mHeight.mFemale << std::endl; + << mData.mData.mHeight.mFemale << std::endl; std::cout << " Weight: " - << mData.mData.mWeight.mFemale << std::endl; + << mData.mData.mWeight.mFemale << std::endl; for (int i = 0; i != 7; i++) - // Not all races have 7 skills. - if (mData.mData.mBonus[i].mSkill != -1) - std::cout << " Skill: " << mData.mData.mBonus[i].mSkill - << " = " << mData.mData.mBonus[i].mBonus << std::endl; + // Not all races have 7 skills. + if (mData.mData.mBonus[i].mSkill != -1) + std::cout << " Skill: " << mData.mData.mBonus[i].mSkill + << " = " << mData.mData.mBonus[i].mBonus << std::endl; std::vector<std::string>::iterator sit; for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); sit++) - std::cout << " Power: " << *sit << std::endl; + std::cout << " Power: " << *sit << std::endl; } template<> @@ -991,10 +1093,10 @@ void Record<ESM::Region>::print() std::cout << " UnknownB: " << (int)mData.mData.mB << std::endl; std::cout << " Map Color: " << mData.mMapColor << std::endl; if (mData.mSleepList != "") - std::cout << " Sleep List: " << mData.mSleepList << std::endl; + std::cout << " Sleep List: " << mData.mSleepList << std::endl; std::vector<ESM::Region::SoundRef>::iterator sit; for (sit = mData.mSoundList.begin(); sit != mData.mSoundList.end(); sit++) - std::cout << " Sound: " << (int)sit->mChance << " = " << sit->mSound.toString() << std::endl; + std::cout << " Sound: " << (int)sit->mChance << " = " << sit->mSound.toString() << std::endl; } template<> @@ -1009,18 +1111,19 @@ void Record<ESM::Script>::print() std::cout << " Table Size: " << mData.mData.mStringTableSize << std::endl; std::cout << " Script: [skipped]" << std::endl; - // Skip until multi-line field is controllable by a command line option. - //std::cout << "-------------------------------------------" << std::endl; - //std::cout << s->scriptText << std::endl; - //std::cout << "-------------------------------------------" << std::endl; + // Skip until multi-line fields is controllable by a command line option. + // Mildly problematic because there are no parameter to print() currently. + // std::cout << "-------------------------------------------" << std::endl; + // std::cout << s->scriptText << std::endl; + // std::cout << "-------------------------------------------" << std::endl; std::vector<std::string>::iterator vit; for (vit = mData.mVarNames.begin(); vit != mData.mVarNames.end(); vit++) - std::cout << " Variable: " << *vit << std::endl; + std::cout << " Variable: " << *vit << std::endl; std::cout << " ByteCode: "; std::vector<char>::iterator cit; for (cit = mData.mScriptData.begin(); cit != mData.mScriptData.end(); cit++) - std::cout << boost::format("%02X") % (int)(*cit); + std::cout << boost::format("%02X") % (int)(*cit); std::cout << std::endl; } @@ -1055,8 +1158,8 @@ void Record<ESM::Sound>::print() std::cout << " Sound: " << mData.mSound << std::endl; std::cout << " Volume: " << (int)mData.mData.mVolume << std::endl; if (mData.mData.mMinRange != 0 && mData.mData.mMaxRange != 0) - std::cout << " Range: " << (int)mData.mData.mMinRange << " - " - << (int)mData.mData.mMaxRange << std::endl; + std::cout << " Range: " << (int)mData.mData.mMinRange << " - " + << (int)mData.mData.mMaxRange << std::endl; } template<> @@ -1066,7 +1169,7 @@ void Record<ESM::Spell>::print() std::cout << " Type: " << mData.mData.mType << std::endl; std::cout << " Flags: " << mData.mData.mFlags << std::endl; std::cout << " Cost: " << mData.mData.mCost << std::endl; - // mEffect missing + printEffectList(mData.mEffects); } template<> @@ -1087,15 +1190,15 @@ void Record<ESM::Weapon>::print() { // No names on VFX bolts if (mData.mName != "") - std::cout << " Name: " << mData.mName << std::endl; + std::cout << " Name: " << mData.mName << std::endl; std::cout << " Model: " << mData.mModel << std::endl; // No icons on VFX bolts or magic bolts if (mData.mIcon != "") - std::cout << " Icon: " << mData.mIcon << std::endl; + std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") - std::cout << " Script: " << mData.mScript << std::endl; + std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") - std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Enchantment: " << mData.mEnchant << std::endl; std::cout << " Type: " << mData.mData.mType << std::endl; std::cout << " Flags: " << mData.mData.mFlags << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; @@ -1105,14 +1208,14 @@ void Record<ESM::Weapon>::print() std::cout << " Reach: " << mData.mData.mReach << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; if (mData.mData.mChop[0] != 0 && mData.mData.mChop[1] != 0) - std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-" - << (int)mData.mData.mChop[1] << std::endl; + std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-" + << (int)mData.mData.mChop[1] << std::endl; if (mData.mData.mSlash[0] != 0 && mData.mData.mSlash[1] != 0) - std::cout << " Slash: " << (int)mData.mData.mSlash[0] << "-" - << (int)mData.mData.mSlash[1] << std::endl; + std::cout << " Slash: " << (int)mData.mData.mSlash[0] << "-" + << (int)mData.mData.mSlash[1] << std::endl; if (mData.mData.mThrust[0] != 0 && mData.mData.mThrust[1] != 0) - std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-" - << (int)mData.mData.mThrust[1] << std::endl; + std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-" + << (int)mData.mData.mThrust[1] << std::endl; } template<> diff --git a/apps/esmtool/record.hpp b/apps/esmtool/record.hpp index e75870ab69..c3daa9d0c3 100644 --- a/apps/esmtool/record.hpp +++ b/apps/esmtool/record.hpp @@ -20,7 +20,7 @@ namespace EsmTool protected: std::string mId; int mFlags; - ESM::NAME mType; + ESM::NAME mType; public: RecordBase () {} @@ -42,7 +42,7 @@ namespace EsmTool mFlags = flags; } - ESM::NAME getType() const { + ESM::NAME getType() const { return mType; } From 4174d3c235dad55d2ec7a908576861cd51ca3b98 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Wed, 10 Oct 2012 21:31:40 +0200 Subject: [PATCH 029/255] Added new plugin model for the Data Files tab in the launcher --- apps/launcher/CMakeLists.txt | 18 +- apps/launcher/model/datafilesmodel.cpp | 443 +++++++++++++++++++++++++ apps/launcher/model/datafilesmodel.hpp | 67 ++++ apps/launcher/model/esm/esmfile.cpp | 50 +++ apps/launcher/model/esm/esmfile.hpp | 54 +++ apps/launcher/model/modelitem.cpp | 57 ++++ apps/launcher/model/modelitem.hpp | 32 ++ 7 files changed, 718 insertions(+), 3 deletions(-) create mode 100644 apps/launcher/model/datafilesmodel.cpp create mode 100644 apps/launcher/model/datafilesmodel.hpp create mode 100644 apps/launcher/model/esm/esmfile.cpp create mode 100644 apps/launcher/model/esm/esmfile.hpp create mode 100644 apps/launcher/model/modelitem.cpp create mode 100644 apps/launcher/model/modelitem.hpp diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 2bc43db80a..53631ebdde 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -1,5 +1,6 @@ set(LAUNCHER datafilespage.cpp + filedialog.cpp graphicspage.cpp lineedit.cpp main.cpp @@ -8,14 +9,18 @@ set(LAUNCHER playpage.cpp pluginsmodel.cpp pluginsview.cpp - filedialog.cpp launcher.rc + + model/datafilesmodel.cpp + model/modelitem.cpp + model/esm/esmfile.cpp ) set(LAUNCHER_HEADER combobox.hpp datafilespage.hpp + filedialog.hpp graphicspage.hpp lineedit.hpp maindialog.hpp @@ -23,20 +28,27 @@ set(LAUNCHER_HEADER playpage.hpp pluginsmodel.hpp pluginsview.hpp - filedialog.hpp + + model/datafilesmodel.hpp + model/modelitem.hpp + model/esm/esmfile.hpp ) # Headers that must be pre-processed set(LAUNCHER_HEADER_MOC combobox.hpp datafilespage.hpp + filedialog.hpp graphicspage.hpp lineedit.hpp maindialog.hpp playpage.hpp pluginsmodel.hpp pluginsview.hpp - filedialog.hpp + + model/datafilesmodel.hpp + model/modelitem.hpp + model/esm/esmfile.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp new file mode 100644 index 0000000000..be89902c8c --- /dev/null +++ b/apps/launcher/model/datafilesmodel.cpp @@ -0,0 +1,443 @@ +#include <QDebug> +#include <QFileInfo> +#include <QDir> + +#include <components/esm/esm_reader.hpp> + +#include "esm/esmfile.hpp" + +#include "datafilesmodel.hpp" +#include "../naturalsort.hpp" + +DataFilesModel::DataFilesModel(QObject *parent) : + QAbstractTableModel(parent) +{ +} + +DataFilesModel::~DataFilesModel() +{ +} + +void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state) +{ + setData(index, state, Qt::CheckStateRole); +} + +Qt::CheckState DataFilesModel::checkState(const QModelIndex &index) +{ + EsmFile *file = item(index.row()); + return mCheckStates[file->fileName()]; +} + +int DataFilesModel::columnCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : 9; +} + +int DataFilesModel::rowCount(const QModelIndex &parent) const +{ + return parent.isValid() ? 0 : mFiles.count(); +} + + +bool DataFilesModel::moveRow(int oldrow, int row, const QModelIndex &parent) +{ + if (oldrow < 0 || row < 0 || oldrow == row) + return false; + + emit layoutAboutToBeChanged(); + //emit beginMoveRows(parent, oldrow, oldrow, parent, row); + mFiles.swap(oldrow, row); + //emit endInsertRows(); + emit layoutChanged(); + + return true; +} + +QVariant DataFilesModel::data(const QModelIndex &index, int role) const +{ + if (!index.isValid()) + return QVariant(); + +// if (index.row() < 0 || index.row() >= mPlugins.size()) +// return QVariant(); + + EsmFile *file = mFiles.at(index.row()); + + const int column = index.column(); + + switch (role) { + case Qt::DisplayRole: { + + switch (column) { + case 0: + return file->fileName(); + case 1: + return file->author(); + case 2: + return QString("%1 kB").arg(int((file->size() + 1023) / 1024)); + case 3: + //return file->modified().toString(Qt::TextDate); + return file->modified().toString(Qt::ISODate); + case 4: + return file->accessed().toString(Qt::TextDate); + case 5: + return file->version(); + case 6: + return file->path(); + case 7: + return file->masters().join(", "); + case 8: + return file->description(); + } + } + + case Qt::TextAlignmentRole: { + switch (column) { + case 0: + return Qt::AlignLeft + Qt::AlignVCenter; + case 1: + return Qt::AlignLeft + Qt::AlignVCenter; + case 2: + return Qt::AlignRight + Qt::AlignVCenter; + case 3: + return Qt::AlignRight + Qt::AlignVCenter; + case 4: + return Qt::AlignRight + Qt::AlignVCenter; + case 5: + return Qt::AlignRight + Qt::AlignVCenter; + default: + return Qt::AlignLeft + Qt::AlignVCenter; + } + } + + case Qt::CheckStateRole: { + if (column != 0) + return QVariant(); + return mCheckStates[file->fileName()]; + } + case Qt::ToolTipRole: + { + if (column != 0) + return QVariant(); + + if (file->version() == 0.0f) + return QVariant(); // Data not set + + QString tooltip = + QString("<b>Author:</b> %1<br/> \ + <b>Version:</b> %2<br/> \ + <br/><b>Description:</b><br/>%3<br/> \ + <br/><b>Dependencies: </b>%4<br/>") + .arg(file->author()) + .arg(QString::number(file->version())) + .arg(file->description()) + .arg(file->masters().join(", ")); + + + return tooltip; + + } + default: + return QVariant(); + } + +} + +Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::NoItemFlags; + + EsmFile *file = mFiles.at(index.row()); + + if (mAvailableFiles.contains(file->fileName())) { + if (index.column() == 0) { + return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } else { + return Qt::ItemIsEnabled | Qt::ItemIsSelectable; + } + } else { + if (index.column() == 0) { + return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable; + } else { + return Qt::NoItemFlags | Qt::ItemIsSelectable; + } + } + +} + +QVariant DataFilesModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if (role != Qt::DisplayRole) + return QVariant(); + + if (orientation == Qt::Horizontal) { + switch (section) { + case 0: return tr("Name"); + case 1: return tr("Author"); + case 2: return tr("Size"); + case 3: return tr("Modified"); + case 4: return tr("Accessed"); + case 5: return tr("Version"); + case 6: return tr("Path"); + case 7: return tr("Masters"); + case 8: return tr("Description"); + } + } else { + // Show row numbers + return ++section; + } + + return QVariant(); +} + +bool DataFilesModel::setData(const QModelIndex &index, const QVariant &value, int role) +{ + if (!index.isValid()) + return false; + + if (role == Qt::CheckStateRole) { + + emit layoutAboutToBeChanged(); + + QString name = item(index.row())->fileName(); + mCheckStates[name] = static_cast<Qt::CheckState>(value.toInt()); + + emit checkedItemsChanged(checkedItems(), uncheckedItems()); + emit layoutChanged(); + return true; + } + + return false; +} + +void DataFilesModel::sort(int column, Qt::SortOrder order) +{ + // TODO: Make this more efficient + emit layoutAboutToBeChanged(); + + // A reference list we can sort + QStringList all = uncheckedItems(); + //all.append(uncheckedItems()); + + // Sort the list of items naturally + qSort(all.begin(), all.end(), naturalSortLessThanCI); + + for (int i = 0; i < all.size(); ++i) { + const QString currentItem = all.at(i); + QModelIndex index = indexFromItem(findItem(currentItem)); + + // Move the actual item from the old position to the new + if (index.isValid()) + mFiles.swap(index.row(), i); + } + + emit layoutChanged(); +} + +void DataFilesModel::addFile(EsmFile *file) +{ + emit beginInsertRows(QModelIndex(), mFiles.count(), mFiles.count()); + mFiles.append(file); + emit endInsertRows(); +} + +void DataFilesModel::addMasters(const QString &path) +{ + QDir dir(path); + dir.setNameFilters(QStringList(QLatin1String("*.esp"))); + + // Read the dependencies from the plugins + foreach (const QString &path, dir.entryList()) { + QFileInfo info(dir.absoluteFilePath(path)); + + try { + ESM::ESMReader fileReader; + fileReader.setEncoding(std::string("win1252")); + fileReader.open(dir.absoluteFilePath(path).toStdString()); + + ESM::ESMReader::MasterList mlist = fileReader.getMasters(); + + for (unsigned int i = 0; i < mlist.size(); ++i) { + QString master = QString::fromStdString(mlist[i].name); + + // Add the plugin to the internal dependency map + mDependencies[master].append(path); + + // Don't add esps + if (master.endsWith(".esp", Qt::CaseInsensitive)) + continue; + + EsmFile *file = new EsmFile(master); + + // Add the master to the table + if (findItem(master) == 0) + addFile(file); + + + } + + } catch(std::runtime_error &e) { + // An error occurred while reading the .esp + continue; + } + } + + // See if the masters actually exist in the filesystem + dir.setNameFilters(QStringList(QLatin1String("*.esm"))); + + foreach (const QString &path, dir.entryList()) { + + if (findItem(path) == 0) { + EsmFile *file = new EsmFile(path); + addFile(file); + } + + // Make the master selectable + mAvailableFiles.append(path); + } +} + +void DataFilesModel::addPlugins(const QString &path) +{ + QDir dir(path); + dir.setNameFilters(QStringList(QLatin1String("*.esp"))); + + foreach (const QString &path, dir.entryList()) { + QFileInfo info(dir.absoluteFilePath(path)); + EsmFile *file = new EsmFile(path); + + try { + ESM::ESMReader fileReader; + fileReader.setEncoding(std::string("win1252")); + fileReader.open(dir.absoluteFilePath(path).toStdString()); + + ESM::ESMReader::MasterList mlist = fileReader.getMasters(); + QStringList masters; + + for (unsigned int i = 0; i < mlist.size(); ++i) { + QString master = QString::fromStdString(mlist[i].name); + masters.append(master); + + // Add the plugin to the internal dependency map + mDependencies[master].append(path); + } + + file->setAuthor(QString::fromStdString(fileReader.getAuthor())); + file->setSize(info.size()); + file->setDates(info.lastModified(), info.lastRead()); + file->setVersion(fileReader.getFVer()); + file->setPath(info.absoluteFilePath()); + file->setMasters(masters); + file->setDescription(QString::fromStdString(fileReader.getDesc())); + + + // Put the file in the table + addFile(file); + } catch(std::runtime_error &e) { + // An error occurred while reading the .esp + continue; + } + + } +} + +QModelIndex DataFilesModel::indexFromItem(EsmFile *item) const +{ + if (item) + return createIndex(mFiles.indexOf(item), 0); + + return QModelIndex(); +} + +EsmFile* DataFilesModel::findItem(const QString &name) +{ + QList<EsmFile *>::ConstIterator it; + QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); + + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + + if (name == file->fileName()) + return file; + } + + // Not found + return 0; +} + +EsmFile* DataFilesModel::item(int row) +{ + if (row >= 0 && row < mFiles.count()) + return mFiles.at(row); + else + return 0; +} + +QStringList DataFilesModel::checkedItems() +{ + QStringList list; + QHash<QString, Qt::CheckState>::ConstIterator it; + QHash<QString, Qt::CheckState>::ConstIterator itEnd = mCheckStates.constEnd(); + + for (it = mCheckStates.constBegin(); it != itEnd; ++it) { + if (it.value() == Qt::Checked) { + list << it.key(); + } + } + + return list; +} + +void DataFilesModel::uncheckAll() +{ + emit layoutAboutToBeChanged(); + mCheckStates.clear(); + emit layoutChanged(); +} + +QStringList DataFilesModel::uncheckedItems() +{ + QStringList list; + QStringList checked = checkedItems(); + + QList<EsmFile *>::ConstIterator it; + QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); + + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + + // Add the items that are not in the checked list + if (!checked.contains(file->fileName())) + list << file->fileName(); + } + + return list; +} + +void DataFilesModel::slotcheckedItemsChanged(const QStringList &checkedItems, const QStringList &unCheckedItems) +{ + emit layoutAboutToBeChanged(); + + QStringList list; + + foreach (const QString &file, checkedItems) { + list << mDependencies[file]; + } + + foreach (const QString &file, unCheckedItems) { + foreach (const QString &remove, mDependencies[file]) { + list.removeAll(remove); + } + } + + mAvailableFiles.clear(); + mAvailableFiles.append(list); + + emit layoutChanged(); +} diff --git a/apps/launcher/model/datafilesmodel.hpp b/apps/launcher/model/datafilesmodel.hpp new file mode 100644 index 0000000000..8710ba88d3 --- /dev/null +++ b/apps/launcher/model/datafilesmodel.hpp @@ -0,0 +1,67 @@ +#ifndef DATAFILESMODEL_HPP +#define DATAFILESMODEL_HPP + +#include <QAbstractTableModel> +#include <QStringList> +#include <QString> +#include <QHash> + + +class EsmFile; + +class DataFilesModel : public QAbstractTableModel +{ + Q_OBJECT + +public: + explicit DataFilesModel(QObject *parent = 0); + virtual ~DataFilesModel(); + virtual int columnCount(const QModelIndex &parent = QModelIndex()) const; + virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; + + bool moveRow(int oldrow, int row, const QModelIndex &parent = QModelIndex()); + + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + + virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + void sort(int column, Qt::SortOrder order = Qt::AscendingOrder); + + inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const + { return QAbstractTableModel::index(row, column, parent); } + + void addFile(EsmFile *file); + + void addMasters(const QString &path); + void addPlugins(const QString &path); + + void uncheckAll(); + + QStringList checkedItems(); + QStringList uncheckedItems(); + + Qt::CheckState checkState(const QModelIndex &index); + void setCheckState(const QModelIndex &index, Qt::CheckState state); + + QModelIndex indexFromItem(EsmFile *item) const; + EsmFile* findItem(const QString &name); + EsmFile* item(int row); + +signals: + void checkedItemsChanged(const QStringList checkedItems, const QStringList unCheckedItems); + +public slots: + void slotcheckedItemsChanged(const QStringList &checkedItems, const QStringList &unCheckedItems); + +private: + QList<EsmFile *> mFiles; + QStringList mAvailableFiles; + + QHash<QString, QStringList> mDependencies; + QHash<QString, Qt::CheckState> mCheckStates; + +}; + +#endif // DATAFILESMODEL_HPP diff --git a/apps/launcher/model/esm/esmfile.cpp b/apps/launcher/model/esm/esmfile.cpp new file mode 100644 index 0000000000..93d83091e7 --- /dev/null +++ b/apps/launcher/model/esm/esmfile.cpp @@ -0,0 +1,50 @@ +#include "esmfile.hpp" + +EsmFile::EsmFile(QString fileName, ModelItem *parent) + : ModelItem(parent) +{ + mFileName = fileName; + mSize = 0; + mVersion = 0.0f; +} + +void EsmFile::setFileName(const QString &fileName) +{ + mFileName = fileName; +} + +void EsmFile::setAuthor(const QString &author) +{ + mAuthor = author; +} + +void EsmFile::setSize(const int size) +{ + mSize = size; +} + +void EsmFile::setDates(const QDateTime &modified, const QDateTime &accessed) +{ + mModified = modified; + mAccessed = accessed; +} + +void EsmFile::setVersion(float version) +{ + mVersion = version; +} + +void EsmFile::setPath(const QString &path) +{ + mPath = path; +} + +void EsmFile::setMasters(const QStringList &masters) +{ + mMasters = masters; +} + +void EsmFile::setDescription(const QString &description) +{ + mDescription = description; +} diff --git a/apps/launcher/model/esm/esmfile.hpp b/apps/launcher/model/esm/esmfile.hpp new file mode 100644 index 0000000000..ad267aa753 --- /dev/null +++ b/apps/launcher/model/esm/esmfile.hpp @@ -0,0 +1,54 @@ +#ifndef ESMFILE_HPP +#define ESMFILE_HPP + +#include <QDateTime> +#include <QStringList> + +#include "../modelitem.hpp" + +class EsmFile : public ModelItem +{ + Q_OBJECT + Q_PROPERTY(QString filename READ fileName) + +public: + EsmFile(QString fileName = QString(), ModelItem *parent = 0); + + ~EsmFile() + {} + + void setFileName(const QString &fileName); + void setAuthor(const QString &author); + void setSize(const int size); + void setDates(const QDateTime &modified, const QDateTime &accessed); + void setVersion(const float version); + void setPath(const QString &path); + void setMasters(const QStringList &masters); + void setDescription(const QString &description); + + inline QString fileName() { return mFileName; } + inline QString author() { return mAuthor; } + inline int size() { return mSize; } + inline QDateTime modified() { return mModified; } + inline QDateTime accessed() { return mAccessed; } + inline float version() { return mVersion; } + inline QString path() { return mPath; } + inline QStringList masters() { return mMasters; } + inline QString description() { return mDescription; } + + +private: + QString mFileName; + QString mAuthor; + int mSize; + QDateTime mModified; + QDateTime mAccessed; + float mVersion; + QString mPath; + QStringList mMasters; + QString mDescription; + +}; + + +#endif diff --git a/apps/launcher/model/modelitem.cpp b/apps/launcher/model/modelitem.cpp new file mode 100644 index 0000000000..0ff7e45cb9 --- /dev/null +++ b/apps/launcher/model/modelitem.cpp @@ -0,0 +1,57 @@ +#include "modelitem.hpp" + +ModelItem::ModelItem(ModelItem *parent) + : mParentItem(parent) + , QObject(parent) +{ +} + +ModelItem::~ModelItem() +{ + qDeleteAll(mChildItems); +} + + +ModelItem *ModelItem::parent() +{ + return mParentItem; +} + +int ModelItem::row() const +{ + if (mParentItem) + return 1; + //return mParentItem->childRow(const_cast<ModelItem*>(this)); + //return mParentItem->mChildItems.indexOf(const_cast<ModelItem*>(this)); + + return -1; +} + + +int ModelItem::childCount() const +{ + return mChildItems.count(); +} + +int ModelItem::childRow(ModelItem *child) const +{ + Q_ASSERT(child); + + return mChildItems.indexOf(child); +} + +ModelItem *ModelItem::child(int row) +{ + return mChildItems.value(row); +} + + +void ModelItem::appendChild(ModelItem *item) +{ + mChildItems.append(item); +} + +void ModelItem::removeChild(int row) +{ + mChildItems.removeAt(row); +} diff --git a/apps/launcher/model/modelitem.hpp b/apps/launcher/model/modelitem.hpp new file mode 100644 index 0000000000..f4cb4322ff --- /dev/null +++ b/apps/launcher/model/modelitem.hpp @@ -0,0 +1,32 @@ +#ifndef MODELITEM_HPP +#define MODELITEM_HPP + +#include <QObject> +#include <QList> + +class ModelItem : public QObject +{ + Q_OBJECT + +public: + ModelItem(ModelItem *parent = 0); + ~ModelItem(); + + ModelItem *parent(); + int row() const; + + int childCount() const; + int childRow(ModelItem *child) const; + ModelItem *child(int row); + + void appendChild(ModelItem *child); + void removeChild(int row); + + //virtual bool acceptChild(ModelItem *child); + +protected: + ModelItem *mParentItem; + QList<ModelItem*> mChildItems; +}; + +#endif From 57736769860c97eede190dfd6d3cfd92d5b2e37a Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Wed, 10 Oct 2012 22:58:04 +0200 Subject: [PATCH 030/255] Got the Data Files tab to use the new model --- apps/launcher/datafilespage.cpp | 1210 ++++++++---------------- apps/launcher/datafilespage.hpp | 49 +- apps/launcher/model/datafilesmodel.cpp | 2 +- 3 files changed, 395 insertions(+), 866 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 8ca3c9aed7..c0a447e263 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -3,12 +3,14 @@ #include <components/esm/esmreader.hpp> #include <components/files/configurationmanager.hpp> +#include "model/datafilesmodel.hpp" +#include "model/esm/esmfile.hpp" + +#include "combobox.hpp" #include "datafilespage.hpp" -#include "lineedit.hpp" #include "filedialog.hpp" +#include "lineedit.hpp" #include "naturalsort.hpp" -#include "pluginsmodel.hpp" -#include "pluginsview.hpp" #include <boost/version.hpp> /** @@ -46,13 +48,15 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) : QWidget(parent) , mCfgMgr(cfg) { - mDataFilesModel = new QStandardItemModel(); // Contains all plugins with masters - mPluginsModel = new PluginsModel(); // Contains selectable plugins + // Models + mMastersModel = new DataFilesModel(this); + mPluginsModel = new DataFilesModel(this); mPluginsProxyModel = new QSortFilterProxyModel(); mPluginsProxyModel->setDynamicSortFilter(true); mPluginsProxyModel->setSourceModel(mPluginsModel); + // Filter toolbar QLabel *filterLabel = new QLabel(tr("&Filter:"), this); LineEdit *filterLineEdit = new LineEdit(this); filterLabel->setBuddy(filterLineEdit); @@ -71,40 +75,62 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) filterToolBar->addWidget(filterWidget); - mMastersWidget = new QTableWidget(this); // Contains the available masters - mMastersWidget->setObjectName("MastersWidget"); - mMastersWidget->setSelectionBehavior(QAbstractItemView::SelectRows); - mMastersWidget->setSelectionMode(QAbstractItemView::MultiSelection); - mMastersWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); - mMastersWidget->setAlternatingRowColors(true); - mMastersWidget->horizontalHeader()->setStretchLastSection(true); - mMastersWidget->horizontalHeader()->hide(); - mMastersWidget->verticalHeader()->hide(); - mMastersWidget->insertColumn(0); - - mPluginsTable = new PluginsView(this); - mPluginsTable->setModel(mPluginsProxyModel); - mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); - - mPluginsTable->horizontalHeader()->setStretchLastSection(true); - mPluginsTable->horizontalHeader()->hide(); - - // Set the row height to the size of the checkboxes QCheckBox checkBox; unsigned int height = checkBox.sizeHint().height() + 4; + mMastersTable = new QTableView(this); + mMastersTable->setModel(mMastersModel); + mMastersTable->setObjectName("MastersTable"); + mMastersTable->setSelectionBehavior(QAbstractItemView::SelectRows); + mMastersTable->setSelectionMode(QAbstractItemView::SingleSelection); + mMastersTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + mMastersTable->setAlternatingRowColors(true); + mMastersTable->horizontalHeader()->setStretchLastSection(true); + mMastersTable->horizontalHeader()->hide(); + + // Set the row height to the size of the checkboxes + mMastersTable->verticalHeader()->setDefaultSectionSize(height); + mMastersTable->verticalHeader()->hide(); + mMastersTable->setColumnHidden(1, true); + mMastersTable->setColumnHidden(2, true); + mMastersTable->setColumnHidden(3, true); + mMastersTable->setColumnHidden(4, true); + mMastersTable->setColumnHidden(5, true); + mMastersTable->setColumnHidden(6, true); + mMastersTable->setColumnHidden(7, true); + mMastersTable->setColumnHidden(8, true); + + mPluginsTable = new QTableView(this); + mPluginsTable->setModel(mPluginsProxyModel); + mPluginsTable->setObjectName("PluginsTable"); + mPluginsTable->setContextMenuPolicy(Qt::CustomContextMenu); + mPluginsTable->setSelectionBehavior(QAbstractItemView::SelectRows); + mPluginsTable->setSelectionMode(QAbstractItemView::SingleSelection); + mPluginsTable->setEditTriggers(QAbstractItemView::NoEditTriggers); + mPluginsTable->setAlternatingRowColors(true); + mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); + mPluginsTable->horizontalHeader()->setStretchLastSection(true); + mPluginsTable->verticalHeader()->setDefaultSectionSize(height); + mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); + mPluginsTable->setColumnHidden(1, true); + mPluginsTable->setColumnHidden(2, true); + mPluginsTable->setColumnHidden(3, true); + mPluginsTable->setColumnHidden(4, true); + mPluginsTable->setColumnHidden(5, true); + mPluginsTable->setColumnHidden(6, true); + mPluginsTable->setColumnHidden(7, true); + mPluginsTable->setColumnHidden(8, true); // Add both tables to a splitter QSplitter *splitter = new QSplitter(this); splitter->setOrientation(Qt::Horizontal); - - splitter->addWidget(mMastersWidget); + splitter->addWidget(mMastersTable); splitter->addWidget(mPluginsTable); // Adjust the default widget widths inside the splitter QList<int> sizeList; - sizeList << 100 << 300; + sizeList << 175 << 200; splitter->setSizes(sizeList); // Bottom part with profile options @@ -127,20 +153,56 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) pageLayout->addWidget(splitter); pageLayout->addWidget(mProfileToolBar); - connect(mMastersWidget->selectionModel(), - SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), - this, SLOT(masterSelectionChanged(const QItemSelection&, const QItemSelection&))); + connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); + connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); + + connect(mMastersModel, SIGNAL(checkedItemsChanged(QStringList,QStringList)), mPluginsModel, SLOT(slotcheckedItemsChanged(QStringList,QStringList))); connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(const QString))); - connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mPluginsTable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&))); createActions(); setupConfig(); - //setupDataFiles(); +} + +void DataFilesPage::createActions() +{ + // Refresh the plugins + QAction *refreshAction = new QAction(tr("Refresh"), this); + refreshAction->setShortcut(QKeySequence(tr("F5"))); + connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh())); + + // Profile actions + mNewProfileAction = new QAction(QIcon::fromTheme("document-new"), tr("&New Profile"), this); + mNewProfileAction->setToolTip(tr("New Profile")); + mNewProfileAction->setShortcut(QKeySequence(tr("Ctrl+N"))); + connect(mNewProfileAction, SIGNAL(triggered()), this, SLOT(newProfile())); + + mDeleteProfileAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Profile"), this); + mDeleteProfileAction->setToolTip(tr("Delete Profile")); + mDeleteProfileAction->setShortcut(QKeySequence(tr("Delete"))); + connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile())); + + // Add the newly created actions to the toolbar + mProfileToolBar->addSeparator(); + mProfileToolBar->addAction(mNewProfileAction); + mProfileToolBar->addAction(mDeleteProfileAction); + + // Context menu actions + mCheckAction = new QAction(tr("Check selected"), this); + connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check())); + + mUncheckAction = new QAction(tr("Uncheck selected"), this); + connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck())); + + // Context menu for the plugins table + mContextMenu = new QMenu(this); + + mContextMenu->addAction(mCheckAction); + mContextMenu->addAction(mUncheckAction); } @@ -189,111 +251,81 @@ void DataFilesPage::setupConfig() } -void DataFilesPage::addDataFiles(Files::Collections &fileCollections, const QString &encoding) +void DataFilesPage::readConfig() { - // First we add all the master files - const Files::MultiDirCollection &esm = fileCollections.getCollection(".esm"); - unsigned int i = 0; // Row number + // Don't read the config if no masters are found + if (mMastersModel->rowCount() < 1) + return; - for (Files::MultiDirCollection::TIter iter(esm.begin()); iter!=esm.end(); ++iter) { - QString currentMaster = QString::fromStdString( - boost::filesystem::path (iter->second.filename()).string()); + QString profile = mProfilesComboBox->currentText(); - const QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); + // Make sure we have no groups open + while (!mLauncherConfig->group().isEmpty()) { + mLauncherConfig->endGroup(); + } - if (itemList.isEmpty()) { // Master is not yet in the widget - mMastersWidget->insertRow(i); - QTableWidgetItem *item = new QTableWidgetItem(currentMaster); - mMastersWidget->setItem(i, 0, item); - ++i; + mLauncherConfig->beginGroup("Profiles"); + mLauncherConfig->beginGroup(profile); + + QStringList childKeys = mLauncherConfig->childKeys(); + QStringList plugins; + + // Sort the child keys numerical instead of alphabetically + // i.e. Plugin1, Plugin2 instead of Plugin1, Plugin10 + qSort(childKeys.begin(), childKeys.end(), naturalSortLessThanCI); + + foreach (const QString &key, childKeys) { + const QString keyValue = mLauncherConfig->value(key).toString(); + + if (key.startsWith("Plugin")) { + //QStringList checked = mPluginsModel->checkedItems(); + EsmFile *file = mPluginsModel->findItem(keyValue); + QModelIndex index = mPluginsModel->indexFromItem(file); + + mPluginsModel->setCheckState(index, Qt::Checked); + // Move the row to the top of te view + //mPluginsModel->moveRow(index.row(), checked.count()); + plugins << keyValue; + } + + if (key.startsWith("Master")) { + EsmFile *file = mMastersModel->findItem(keyValue); + mMastersModel->setCheckState(mMastersModel->indexFromItem(file), Qt::Checked); } } - // Now on to the plugins - const Files::MultiDirCollection &esp = fileCollections.getCollection(".esp"); + qDebug() << plugins; - for (Files::MultiDirCollection::TIter iter(esp.begin()); iter!=esp.end(); ++iter) { - try { - ESMReader fileReader; - QStringList availableMasters; // Will contain all found masters +// // Set the checked item positions +// const QStringList checked = mPluginsModel->checkedItems(); +// for (int i = 0; i < plugins.size(); ++i) { +// EsmFile *file = mPluginsModel->findItem(plugins.at(i)); +// QModelIndex index = mPluginsModel->indexFromItem(file); +// mPluginsModel->moveRow(index.row(), i); +// qDebug() << "Moving: " << plugins.at(i) << " from: " << index.row() << " to: " << i << " count: " << checked.count(); - fileReader.setEncoding(encoding.toStdString()); - fileReader.open(iter->second.string()); +// } - // First we fill the availableMasters and the mMastersWidget - ESMReader::MasterList mlist = fileReader.getMasters(); + // Iterate over the plugins to set their checkstate and position +// for (int i = 0; i < plugins.size(); ++i) { +// const QString plugin = plugins.at(i); - for (unsigned int i = 0; i < mlist.size(); ++i) { - const QString currentMaster = QString::fromStdString(mlist[i].name); - availableMasters.append(currentMaster); +// const QList<QStandardItem *> pluginList = mPluginsModel->findItems(plugin); - const QList<QTableWidgetItem*> itemList = mMastersWidget->findItems(currentMaster, Qt::MatchExactly); - - if (itemList.isEmpty()) { // Master is not yet in the widget - mMastersWidget->insertRow(i); - - QTableWidgetItem *item = new QTableWidgetItem(currentMaster); - item->setForeground(Qt::red); - item->setFlags(item->flags() & ~(Qt::ItemIsSelectable)); - - mMastersWidget->setItem(i, 0, item); - } - } - - availableMasters.sort(); // Sort the masters alphabetically - - // Now we put the current plugin in the mDataFilesModel under its masters - QStandardItem *parent = new QStandardItem(availableMasters.join(",")); - - QString fileName = QString::fromStdString(boost::filesystem::path (iter->second.filename()).string()); - QStandardItem *child = new QStandardItem(fileName); - - // Tooltip information - QString author = QString::fromStdString(fileReader.getAuthor()); - float version = fileReader.getFVer(); - QString description = QString::fromStdString(fileReader.getDesc()); - - // For the date created/modified - QFileInfo fi(QString::fromStdString(iter->second.string())); - - QString toolTip= QString("<b>Author:</b> %1<br/> \ - <b>Version:</b> %2<br/><br/> \ - <b>Description:</b><br/> \ - %3<br/><br/> \ - <b>Created on:</b> %4<br/> \ - <b>Last modified:</b> %5") - .arg(author) - .arg(version) - .arg(description) - .arg(fi.created().toString(Qt::TextDate)) - .arg(fi.lastModified().toString(Qt::TextDate)); - - child->setToolTip(toolTip); - - const QList<QStandardItem*> masterList = mDataFilesModel->findItems(availableMasters.join(",")); - - if (masterList.isEmpty()) { // Masters node not yet in the mDataFilesModel - parent->appendRow(child); - mDataFilesModel->appendRow(parent); - } else { - // Masters node exists, append current plugin - foreach (QStandardItem *currentItem, masterList) { - currentItem->appendRow(child); - } - } - - } catch(std::runtime_error &e) { - // An error occurred while reading the .esp - std::cerr << "Error reading .esp: " << e.what() << std::endl; - continue; - } - } +// if (!pluginList.isEmpty()) +// { +// foreach (const QStandardItem *currentPlugin, pluginList) { +// mPluginsModel->setData(currentPlugin->index(), Qt::Checked, Qt::CheckStateRole); +// // Move the plugin to the position specified in the config file +// mPluginsModel->insertRow(i, mPluginsModel->takeRow(currentPlugin->row())); +// } +// } +// } } - bool DataFilesPage::setupDataFiles() { // We use the Configuration Manager to retrieve the configuration values @@ -356,717 +388,35 @@ bool DataFilesPage::setupDataFiles() } } - // Add the plugins in the data directories - Files::Collections dataCollections(mDataDirs, !variables["fs-strict"].as<bool>()); - Files::Collections dataLocalCollections(mDataLocal, !variables["fs-strict"].as<bool>()); + // Add the paths to the respective models + for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { + QString path = QString::fromStdString(it->string()); + path.remove(QChar('\"')); + mMastersModel->addMasters(path); + mPluginsModel->addPlugins(path); + } - addDataFiles(dataCollections, QString::fromStdString(variables["encoding"].as<std::string>())); - addDataFiles(dataLocalCollections, QString::fromStdString(variables["encoding"].as<std::string>())); + // Same for the data-local paths + for (Files::PathContainer::iterator it = mDataLocal.begin(); it != mDataLocal.end(); ++it) { + QString path = QString::fromStdString(it->string()); + path.remove(QChar('\"')); + mMastersModel->addMasters(path); + mPluginsModel->addPlugins(path); + } + +// mMastersModel->sort(0); +// mPluginsModel->sort(0); - mDataFilesModel->sort(0); readConfig(); return true; } -void DataFilesPage::createActions() -{ - // Refresh the plugins - QAction *refreshAction = new QAction(tr("Refresh"), this); - refreshAction->setShortcut(QKeySequence(tr("F5"))); - connect(refreshAction, SIGNAL(triggered()), this, SLOT(refresh())); - - // Profile actions - mNewProfileAction = new QAction(QIcon::fromTheme("document-new"), tr("&New Profile"), this); - mNewProfileAction->setToolTip(tr("New Profile")); - mNewProfileAction->setShortcut(QKeySequence(tr("Ctrl+N"))); - connect(mNewProfileAction, SIGNAL(triggered()), this, SLOT(newProfile())); - - - mCopyProfileAction = new QAction(QIcon::fromTheme("edit-copy"), tr("&Copy Profile"), this); - mCopyProfileAction->setToolTip(tr("Copy Profile")); - mCopyProfileAction->setShortcut(QKeySequence(tr("Ctrl+C"))); - connect(mCopyProfileAction, SIGNAL(triggered()), this, SLOT(copyProfile())); - - mDeleteProfileAction = new QAction(QIcon::fromTheme("edit-delete"), tr("Delete Profile"), this); - mDeleteProfileAction->setToolTip(tr("Delete Profile")); - mDeleteProfileAction->setShortcut(QKeySequence(tr("Delete"))); - connect(mDeleteProfileAction, SIGNAL(triggered()), this, SLOT(deleteProfile())); - - // Add the newly created actions to the toolbar - mProfileToolBar->addSeparator(); - mProfileToolBar->addAction(mNewProfileAction); - mProfileToolBar->addAction(mCopyProfileAction); - mProfileToolBar->addAction(mDeleteProfileAction); - - // Context menu actions - mMoveUpAction = new QAction(QIcon::fromTheme("go-up"), tr("Move &Up"), this); - mMoveUpAction->setShortcut(QKeySequence(tr("Ctrl+U"))); - connect(mMoveUpAction, SIGNAL(triggered()), this, SLOT(moveUp())); - - mMoveDownAction = new QAction(QIcon::fromTheme("go-down"), tr("&Move Down"), this); - mMoveDownAction->setShortcut(QKeySequence(tr("Ctrl+M"))); - connect(mMoveDownAction, SIGNAL(triggered()), this, SLOT(moveDown())); - - mMoveTopAction = new QAction(QIcon::fromTheme("go-top"), tr("Move to Top"), this); - mMoveTopAction->setShortcut(QKeySequence(tr("Ctrl+Shift+U"))); - connect(mMoveTopAction, SIGNAL(triggered()), this, SLOT(moveTop())); - - mMoveBottomAction = new QAction(QIcon::fromTheme("go-bottom"), tr("Move to Bottom"), this); - mMoveBottomAction->setShortcut(QKeySequence(tr("Ctrl+Shift+M"))); - connect(mMoveBottomAction, SIGNAL(triggered()), this, SLOT(moveBottom())); - - mCheckAction = new QAction(tr("Check selected"), this); - connect(mCheckAction, SIGNAL(triggered()), this, SLOT(check())); - - mUncheckAction = new QAction(tr("Uncheck selected"), this); - connect(mUncheckAction, SIGNAL(triggered()), this, SLOT(uncheck())); - - // Makes shortcuts work even if the context menu is hidden - this->addAction(refreshAction); - this->addAction(mMoveUpAction); - this->addAction(mMoveDownAction); - this->addAction(mMoveTopAction); - this->addAction(mMoveBottomAction); - - // Context menu for the plugins table - mContextMenu = new QMenu(this); - - mContextMenu->addAction(mMoveUpAction); - mContextMenu->addAction(mMoveDownAction); - mContextMenu->addSeparator(); - mContextMenu->addAction(mMoveTopAction); - mContextMenu->addAction(mMoveBottomAction); - mContextMenu->addSeparator(); - mContextMenu->addAction(mCheckAction); - mContextMenu->addAction(mUncheckAction); - -} - -void DataFilesPage::newProfile() -{ - bool ok; - QString text = QInputDialog::getText(this, tr("New Profile"), - tr("Profile Name:"), QLineEdit::Normal, - tr("New Profile"), &ok); - if (ok && !text.isEmpty()) { - if (mProfilesComboBox->findText(text) != -1) { - QMessageBox::warning(this, tr("Profile already exists"), - tr("the profile <b>%0</b> already exists.").arg(text), - QMessageBox::Ok); - } else { - // Add the new profile to the combobox - mProfilesComboBox->addItem(text); - mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); - - } - - } - -} - -void DataFilesPage::copyProfile() -{ - QString profile = mProfilesComboBox->currentText(); - bool ok; - - QString text = QInputDialog::getText(this, tr("Copy Profile"), - tr("Profile Name:"), QLineEdit::Normal, - tr("%0 Copy").arg(profile), &ok); - if (ok && !text.isEmpty()) { - if (mProfilesComboBox->findText(text) != -1) { - QMessageBox::warning(this, tr("Profile already exists"), - tr("the profile <b>%0</b> already exists.").arg(text), - QMessageBox::Ok); - } else { - // Add the new profile to the combobox - mProfilesComboBox->addItem(text); - - // First write the current profile as the new profile - writeConfig(text); - mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); - - } - - } - -} - -void DataFilesPage::deleteProfile() -{ - QString profile = mProfilesComboBox->currentText(); - - - if (profile.isEmpty()) { - return; - } - - QMessageBox msgBox(this); - msgBox.setWindowTitle(tr("Delete Profile")); - msgBox.setIcon(QMessageBox::Warning); - msgBox.setStandardButtons(QMessageBox::Cancel); - msgBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile)); - - QAbstractButton *deleteButton = - msgBox.addButton(tr("Delete"), QMessageBox::ActionRole); - - msgBox.exec(); - - if (msgBox.clickedButton() == deleteButton) { - // Make sure we have no groups open - while (!mLauncherConfig->group().isEmpty()) { - mLauncherConfig->endGroup(); - } - - mLauncherConfig->beginGroup("Profiles"); - - // Open the profile-name subgroup - mLauncherConfig->beginGroup(profile); - mLauncherConfig->remove(""); // Clear the subgroup - mLauncherConfig->endGroup(); - mLauncherConfig->endGroup(); - - // Remove the profile from the combobox - mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile)); - } -} - -void DataFilesPage::moveUp() -{ - // Shift the selected plugins up one row - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - QModelIndex firstIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - - // Check if the first selected plugin is the top one - if (firstIndex.row() == 0) { - return; - } - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); - int currentRow = sourceModelIndex.row(); - - if (sourceModelIndex.isValid() && currentRow > 0) { - mPluginsModel->insertRow((currentRow - 1), mPluginsModel->takeRow(currentRow)); - - const QModelIndex targetIndex = mPluginsModel->index((currentRow - 1), 0, QModelIndex()); - - mPluginsTable->selectionModel()->select(targetIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); - scrollToSelection(); - } - } -} - -void DataFilesPage::moveDown() -{ - // Shift the selected plugins down one row - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection descending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowGreaterThan); - - const QModelIndex lastIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - - // Check if last selected plugin is bottom one - if ((lastIndex.row() + 1) == mPluginsModel->rowCount()) { - return; - } - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); - int currentRow = sourceModelIndex.row(); - - if (sourceModelIndex.isValid() && (currentRow + 1) < mPluginsModel->rowCount()) { - mPluginsModel->insertRow((currentRow + 1), mPluginsModel->takeRow(currentRow)); - - const QModelIndex targetIndex = mPluginsModel->index((currentRow + 1), 0, QModelIndex()); - - mPluginsTable->selectionModel()->select(targetIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows); - scrollToSelection(); - } - } -} - -void DataFilesPage::moveTop() -{ - // Move the selection to the top of the table - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - QModelIndex firstIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - - // Check if the first selected plugin is the top one - if (firstIndex.row() == 0) { - return; - } - - for (int i=0; i < selectedIndexes.count(); ++i) { - - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(selectedIndexes.at(i)); - - int currentRow = sourceModelIndex.row(); - - if (sourceModelIndex.isValid() && currentRow > 0) { - - mPluginsModel->insertRow(i, mPluginsModel->takeRow(currentRow)); - mPluginsTable->selectionModel()->select(mPluginsModel->index(i, 0, QModelIndex()), QItemSelectionModel::Select | QItemSelectionModel::Rows); - mPluginsTable->scrollToTop(); - } - } -} - -void DataFilesPage::moveBottom() -{ - // Move the selection to the bottom of the table - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection descending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - const QModelIndex lastIndex = mPluginsProxyModel->mapToSource(selectedIndexes.last()); - - // Check if last selected plugin is bottom one - if ((lastIndex.row() + 1) == mPluginsModel->rowCount()) { - return; - } - - for (int i=0; i < selectedIndexes.count(); ++i) { - - const QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(selectedIndexes.at(i)); - - // Subtract iterations because takeRow shifts the rows below the taken row up - int currentRow = sourceModelIndex.row() - i; - - if (sourceModelIndex.isValid() && (currentRow + 1) < mPluginsModel->rowCount()) { - mPluginsModel->appendRow(mPluginsModel->takeRow(currentRow)); - - // Rowcount starts with 1, row numbers start with 0 - const QModelIndex lastRow = mPluginsModel->index((mPluginsModel->rowCount() -1), 0, QModelIndex()); - - mPluginsTable->selectionModel()->select(lastRow, QItemSelectionModel::Select | QItemSelectionModel::Rows); - mPluginsTable->scrollToBottom(); - } - } -} - -void DataFilesPage::check() -{ - // Check the current selection - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); - - if (sourceModelIndex.isValid()) { - mPluginsModel->setData(sourceModelIndex, Qt::Checked, Qt::CheckStateRole); - } - } -} - -void DataFilesPage::uncheck() -{ - // Uncheck the current selection - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - //sort selection ascending because selectedIndexes returns an unsorted list - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(currentIndex); - - if (sourceModelIndex.isValid()) { - mPluginsModel->setData(sourceModelIndex, Qt::Unchecked, Qt::CheckStateRole); - } - } -} - -void DataFilesPage::refresh() -{ - // Refresh the plugins table - - writeConfig(); - readConfig(); -} - -void DataFilesPage::scrollToSelection() -{ - // Scroll to the selected plugins - - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - // Get the selected indexes visible by determining the middle index - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - qSort(selectedIndexes.begin(), selectedIndexes.end(), rowSmallerThan); - - // The selected rows including non-selected inside selection - unsigned int selectedRows = selectedIndexes.last().row() - selectedIndexes.first().row(); - - // Determine the row which is roughly in the middle of the selection - unsigned int middleRow = selectedIndexes.first().row() + (int)(selectedRows / 2) + 1; - - - const QModelIndex middleIndex = mPluginsProxyModel->mapFromSource(mPluginsModel->index(middleRow, 0, QModelIndex())); - - // Make sure the whole selection is visible - mPluginsTable->scrollTo(selectedIndexes.first()); - mPluginsTable->scrollTo(selectedIndexes.last()); - mPluginsTable->scrollTo(middleIndex); -} - -void DataFilesPage::showContextMenu(const QPoint &point) -{ - // Make sure there are plugins in the view - if (!mPluginsTable->selectionModel()->hasSelection()) { - return; - } - - QPoint globalPos = mPluginsTable->mapToGlobal(point); - - QModelIndexList selectedIndexes = mPluginsTable->selectionModel()->selectedIndexes(); - - // Show the check/uncheck actions depending on the state of the selected items - mUncheckAction->setEnabled(false); - mCheckAction->setEnabled(false); - - foreach (const QModelIndex ¤tIndex, selectedIndexes) { - if (currentIndex.isValid()) { - - const QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(currentIndex); - - if (!sourceIndex.isValid()) { - return; - } - - const QStandardItem *currentItem = mPluginsModel->itemFromIndex(sourceIndex); - - if (currentItem->checkState() == Qt::Checked) { - mUncheckAction->setEnabled(true); - } else { - mCheckAction->setEnabled(true); - } - } - - } - - // Make sure these are enabled because they might still be disabled - mMoveUpAction->setEnabled(true); - mMoveTopAction->setEnabled(true); - mMoveDownAction->setEnabled(true); - mMoveBottomAction->setEnabled(true); - - QModelIndex firstIndex = mPluginsProxyModel->mapToSource(selectedIndexes.first()); - QModelIndex lastIndex = mPluginsProxyModel->mapToSource(selectedIndexes.last()); - - // Check if selected first item is top row in model - if (firstIndex.row() == 0) { - mMoveUpAction->setEnabled(false); - mMoveTopAction->setEnabled(false); - } - - // Check if last row is bottom row in model - if ((lastIndex.row() + 1) == mPluginsModel->rowCount()) { - mMoveDownAction->setEnabled(false); - mMoveBottomAction->setEnabled(false); - } - - // Show menu - mContextMenu->exec(globalPos); -} - -void DataFilesPage::masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) -{ - if (mMastersWidget->selectionModel()->hasSelection()) { - - QStringList masters; - QString masterstr; - - // Create a QStringList containing all the masters - const QStringList masterList = selectedMasters(); - - foreach (const QString ¤tMaster, masterList) { - masters.append(currentMaster); - } - - masters.sort(); - masterstr = masters.join(","); // Make a comma-separated QString - - // Iterate over all masters in the datafilesmodel to see if they are selected - for (int r=0; r<mDataFilesModel->rowCount(); ++r) { - QModelIndex currentIndex = mDataFilesModel->index(r, 0); - QString master = currentIndex.data().toString(); - - if (currentIndex.isValid()) { - // See if the current master is in the string with selected masters - if (masterstr.contains(master)) - { - // Append the plugins from the current master to pluginsmodel - addPlugins(currentIndex); - } - } - } - } - - // See what plugins to remove - QModelIndexList deselectedIndexes = deselected.indexes(); - - if (!deselectedIndexes.isEmpty()) { - foreach (const QModelIndex ¤tIndex, deselectedIndexes) { - - QString master = currentIndex.data().toString(); - master.prepend("*"); - master.append("*"); - const QList<QStandardItem *> itemList = mDataFilesModel->findItems(master, Qt::MatchWildcard); - - foreach (const QStandardItem *currentItem, itemList) { - QModelIndex index = currentItem->index(); - removePlugins(index); - } - } - } - -} - -void DataFilesPage::addPlugins(const QModelIndex &index) -{ - // Find the plugins in the datafilesmodel and append them to the pluginsmodel - if (!index.isValid()) - return; - - for (int r=0; r<mDataFilesModel->rowCount(index); ++r ) { - QModelIndex childIndex = index.child(r, 0); - - if (childIndex.isValid()) { - // Now we see if the pluginsmodel already contains this plugin - const QString childIndexData = QVariant(mDataFilesModel->data(childIndex)).toString(); - const QString childIndexToolTip = QVariant(mDataFilesModel->data(childIndex, Qt::ToolTipRole)).toString(); - - const QList<QStandardItem *> itemList = mPluginsModel->findItems(childIndexData); - - if (itemList.isEmpty()) - { - // Plugin not yet in the pluginsmodel, add it - QStandardItem *item = new QStandardItem(childIndexData); - item->setFlags(item->flags() & ~(Qt::ItemIsDropEnabled)); - item->setCheckable(true); - item->setToolTip(childIndexToolTip); - - mPluginsModel->appendRow(item); - } - } - - } - -} - -void DataFilesPage::removePlugins(const QModelIndex &index) -{ - - if (!index.isValid()) - return; - - for (int r=0; r<mDataFilesModel->rowCount(index); ++r) { - QModelIndex childIndex = index.child(r, 0); - - const QList<QStandardItem *> itemList = mPluginsModel->findItems(QVariant(childIndex.data()).toString()); - - if (!itemList.isEmpty()) { - foreach (const QStandardItem *currentItem, itemList) { - mPluginsModel->removeRow(currentItem->row()); - } - } - } - -} - -void DataFilesPage::setCheckState(QModelIndex index) -{ - if (!index.isValid()) - return; - - QModelIndex sourceModelIndex = mPluginsProxyModel->mapToSource(index); - - if (mPluginsModel->data(sourceModelIndex, Qt::CheckStateRole) == Qt::Checked) { - // Selected row is checked, uncheck it - mPluginsModel->setData(sourceModelIndex, Qt::Unchecked, Qt::CheckStateRole); - } else { - mPluginsModel->setData(sourceModelIndex, Qt::Checked, Qt::CheckStateRole); - } -} - -const QStringList DataFilesPage::selectedMasters() -{ - QStringList masters; - const QList<QTableWidgetItem *> selectedMasters = mMastersWidget->selectedItems(); - - foreach (const QTableWidgetItem *item, selectedMasters) { - masters.append(item->data(Qt::DisplayRole).toString()); - } - - return masters; -} - -const QStringList DataFilesPage::checkedPlugins() -{ - QStringList checkedItems; - - for (int r=0; r<mPluginsModel->rowCount(); ++r ) { - QModelIndex index = mPluginsModel->index(r, 0); - - if (index.isValid()) { - // See if the current item is checked - if (mPluginsModel->data(index, Qt::CheckStateRole) == Qt::Checked) { - checkedItems.append(index.data().toString()); - } - } - } - return checkedItems; -} - -void DataFilesPage::uncheckPlugins() -{ - for (int r=0; r<mPluginsModel->rowCount(); ++r ) { - QModelIndex index = mPluginsModel->index(r, 0); - - if (index.isValid()) { - // See if the current item is checked - if (mPluginsModel->data(index, Qt::CheckStateRole) == Qt::Checked) { - mPluginsModel->setData(index, Qt::Unchecked, Qt::CheckStateRole); - } - } - } -} - -void DataFilesPage::filterChanged(const QString filter) -{ - QRegExp regExp(filter, Qt::CaseInsensitive, QRegExp::FixedString); - mPluginsProxyModel->setFilterRegExp(regExp); -} - -void DataFilesPage::profileChanged(const QString &previous, const QString ¤t) -{ - // Prevent the deletion of the default profile - if (current == "Default") { - mDeleteProfileAction->setEnabled(false); - } else { - mDeleteProfileAction->setEnabled(true); - } - - if (!previous.isEmpty()) { - writeConfig(previous); - mLauncherConfig->sync(); - } else { - return; - } - - uncheckPlugins(); - // Deselect the masters - mMastersWidget->selectionModel()->clearSelection(); - readConfig(); -} - -void DataFilesPage::readConfig() -{ - QString profile = mProfilesComboBox->currentText(); - - // Make sure we have no groups open - while (!mLauncherConfig->group().isEmpty()) { - mLauncherConfig->endGroup(); - } - - mLauncherConfig->beginGroup("Profiles"); - mLauncherConfig->beginGroup(profile); - - QStringList childKeys = mLauncherConfig->childKeys(); - QStringList plugins; - - // Sort the child keys numerical instead of alphabetically - // i.e. Plugin1, Plugin2 instead of Plugin1, Plugin10 - qSort(childKeys.begin(), childKeys.end(), naturalSortLessThanCI); - - foreach (const QString &key, childKeys) { - const QString keyValue = mLauncherConfig->value(key).toString(); - - if (key.startsWith("Plugin")) { - plugins.append(keyValue); - continue; - } - - if (key.startsWith("Master")) { - const QList<QTableWidgetItem*> masterList = mMastersWidget->findItems(keyValue, Qt::MatchFixedString); - - if (!masterList.isEmpty()) { - foreach (QTableWidgetItem *currentMaster, masterList) { - mMastersWidget->selectionModel()->select(mMastersWidget->model()->index(currentMaster->row(), 0), QItemSelectionModel::Select); - } - } - } - } - - // Iterate over the plugins to set their checkstate and position - for (int i = 0; i < plugins.size(); ++i) { - const QString plugin = plugins.at(i); - - const QList<QStandardItem *> pluginList = mPluginsModel->findItems(plugin); - - if (!pluginList.isEmpty()) - { - foreach (const QStandardItem *currentPlugin, pluginList) { - mPluginsModel->setData(currentPlugin->index(), Qt::Checked, Qt::CheckStateRole); - - // Move the plugin to the position specified in the config file - mPluginsModel->insertRow(i, mPluginsModel->takeRow(currentPlugin->row())); - } - } - } - -} - void DataFilesPage::writeConfig(QString profile) { // Don't overwrite the config if no masters are found - if (mMastersWidget->rowCount() < 1) { + if (mMastersModel->rowCount() < 1) return; - } QString pathStr = QString::fromStdString(mCfgMgr.getUserPath().string()); QDir userPath(pathStr); @@ -1150,13 +500,11 @@ void DataFilesPage::writeConfig(QString profile) path = QString::fromStdString(it->string()); path.remove(QChar('\"')); - QDir dir(path); - // Make sure the string is quoted when it contains spaces if (path.contains(" ")) { - gameConfig << "data=\"" << dir.absolutePath() << "\"" << endl; + gameConfig << "data=\"" << path << "\"" << endl; } else { - gameConfig << "data=" << dir.absolutePath() << endl; + gameConfig << "data=" << path << endl; } } @@ -1165,23 +513,19 @@ void DataFilesPage::writeConfig(QString profile) path = QString::fromStdString(mDataLocal.front().string()); path.remove(QChar('\"')); - QDir dir(path); - if (path.contains(" ")) { - gameConfig << "data-local=\"" << dir.absolutePath() << "\"" << endl; + gameConfig << "data-local=\"" << path << "\"" << endl; } else { - gameConfig << "data-local=" << dir.absolutePath() << endl; + gameConfig << "data-local=" << path << endl; } } - if (profile.isEmpty()) { + if (profile.isEmpty()) profile = mProfilesComboBox->currentText(); - } - if (profile.isEmpty()) { + if (profile.isEmpty()) return; - } // Make sure we have no groups open while (!mLauncherConfig->group().isEmpty()) { @@ -1196,7 +540,7 @@ void DataFilesPage::writeConfig(QString profile) mLauncherConfig->remove(""); // Clear the subgroup // Now write the masters to the configs - const QStringList masters = selectedMasters(); + const QStringList masters = mMastersModel->checkedItems(); // We don't use foreach because we need i for (int i = 0; i < masters.size(); ++i) { @@ -1208,7 +552,7 @@ void DataFilesPage::writeConfig(QString profile) } // And finally write all checked plugins - const QStringList plugins = checkedPlugins(); + const QStringList plugins = mPluginsModel->checkedItems(); for (int i = 0; i < plugins.size(); ++i) { const QString currentPlugin = plugins.at(i); @@ -1221,3 +565,201 @@ void DataFilesPage::writeConfig(QString profile) mLauncherConfig->endGroup(); mLauncherConfig->sync(); } + + +void DataFilesPage::newProfile() +{ + bool ok; + QString text = QInputDialog::getText(this, tr("New Profile"), + tr("Profile Name:"), QLineEdit::Normal, + tr("New Profile"), &ok); + if (ok && !text.isEmpty()) { + if (mProfilesComboBox->findText(text) != -1) { + QMessageBox::warning(this, tr("Profile already exists"), + tr("the profile <b>%0</b> already exists.").arg(text), + QMessageBox::Ok); + } else { + // Add the new profile to the combobox + mProfilesComboBox->addItem(text); + mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); + + } + + } +} + +void DataFilesPage::deleteProfile() +{ + QString profile = mProfilesComboBox->currentText(); + + + if (profile.isEmpty()) { + return; + } + + QMessageBox msgBox(this); + msgBox.setWindowTitle(tr("Delete Profile")); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setStandardButtons(QMessageBox::Cancel); + msgBox.setText(tr("Are you sure you want to delete <b>%0</b>?").arg(profile)); + + QAbstractButton *deleteButton = + msgBox.addButton(tr("Delete"), QMessageBox::ActionRole); + + msgBox.exec(); + + if (msgBox.clickedButton() == deleteButton) { + // Make sure we have no groups open + while (!mLauncherConfig->group().isEmpty()) { + mLauncherConfig->endGroup(); + } + + mLauncherConfig->beginGroup("Profiles"); + + // Open the profile-name subgroup + mLauncherConfig->beginGroup(profile); + mLauncherConfig->remove(""); // Clear the subgroup + mLauncherConfig->endGroup(); + mLauncherConfig->endGroup(); + + // Remove the profile from the combobox + mProfilesComboBox->removeItem(mProfilesComboBox->findText(profile)); + } +} + +void DataFilesPage::check() +{ + // Check the current selection + if (!mPluginsTable->selectionModel()->hasSelection()) { + return; + } + + QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); + + //sort selection ascending because selectedIndexes returns an unsorted list + //qSort(indexes.begin(), indexes.end(), rowSmallerThan); + + foreach (const QModelIndex &index, indexes) { + if (!index.isValid()) + return; + + mPluginsModel->setCheckState(index, Qt::Checked); + } +} + +void DataFilesPage::uncheck() +{ + // uncheck the current selection + if (!mPluginsTable->selectionModel()->hasSelection()) { + return; + } + + QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); + + //sort selection ascending because selectedIndexes returns an unsorted list + //qSort(indexes.begin(), indexes.end(), rowSmallerThan); + + foreach (const QModelIndex &index, indexes) { + if (!index.isValid()) + return; + + mPluginsModel->setCheckState(index, Qt::Unchecked); + } +} + +void DataFilesPage::refresh() +{ + mPluginsModel->sort(0); + + + // Refresh the plugins table + mPluginsTable->scrollToTop(); + writeConfig(); + readConfig(); +} + + +void DataFilesPage::setCheckState(QModelIndex index) +{ + if (!index.isValid()) + return; + + QObject *object = QObject::sender(); + + // Not a signal-slot call + if (!object) + return; + + if (object->objectName() == QLatin1String("PluginsTable")) { + if (mPluginsModel->checkState(index) == Qt::Checked) { + mPluginsModel->setCheckState(index, Qt::Unchecked); + } else { + mPluginsModel->setCheckState(index, Qt::Checked); + } + } + + if (object->objectName() == QLatin1String("MastersTable")) { + if (mMastersModel->checkState(index) == Qt::Checked) { + mMastersModel->setCheckState(index, Qt::Unchecked); + } else { + mMastersModel->setCheckState(index, Qt::Checked); + } + } + + return; + +} + +void DataFilesPage::filterChanged(const QString filter) +{ + QRegExp regExp(filter, Qt::CaseInsensitive, QRegExp::FixedString); + mPluginsProxyModel->setFilterRegExp(regExp); +} + +void DataFilesPage::profileChanged(const QString &previous, const QString ¤t) +{ + // Prevent the deletion of the default profile + (current == QLatin1String("Default")) ? mDeleteProfileAction->setEnabled(false) + : mDeleteProfileAction->setEnabled(true); + + if (!previous.isEmpty()) { + writeConfig(previous); + mLauncherConfig->sync(); + } else { + return; + } + + mMastersModel->uncheckAll(); + mPluginsModel->uncheckAll(); + readConfig(); +} + +void DataFilesPage::showContextMenu(const QPoint &point) +{ + // Make sure there are plugins in the view + if (!mPluginsTable->selectionModel()->hasSelection()) { + return; + } + + QPoint globalPos = mPluginsTable->mapToGlobal(point); + + QModelIndexList indexes = mPluginsTable->selectionModel()->selectedIndexes(); + + // Show the check/uncheck actions depending on the state of the selected items + mUncheckAction->setEnabled(false); + mCheckAction->setEnabled(false); + + foreach (const QModelIndex &index, indexes) { + if (!index.isValid()) + return; + + if (mPluginsModel->checkState(index) == Qt::Checked) { + mUncheckAction->setEnabled(true); + } else { + mCheckAction->setEnabled(true); + } + } + + // Show menu + mContextMenu->exec(globalPos); +} diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 83b3186772..6489912543 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -8,19 +8,15 @@ #include "combobox.hpp" -class QTableWidget; -class QStandardItemModel; -class QItemSelection; -class QItemSelectionModel; +class QTableView; class QSortFilterProxyModel; -class QStringListModel; class QSettings; class QAction; class QToolBar; class QMenu; -class PluginsModel; -class PluginsView; class ComboBox; +class DataFilesModel; + namespace Files { struct ConfigurationManager; } @@ -37,7 +33,6 @@ public: bool setupDataFiles(); public slots: - void masterSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void setCheckState(QModelIndex index); void filterChanged(const QString filter); @@ -46,37 +41,34 @@ public slots: // Action slots void newProfile(); - void copyProfile(); void deleteProfile(); - void moveUp(); - void moveDown(); - void moveTop(); - void moveBottom(); +// void moveUp(); +// void moveDown(); +// void moveTop(); +// void moveBottom(); void check(); void uncheck(); void refresh(); private: - QTableWidget *mMastersWidget; - PluginsView *mPluginsTable; - - QStandardItemModel *mDataFilesModel; - PluginsModel *mPluginsModel; + DataFilesModel *mMastersModel; + DataFilesModel *mPluginsModel; QSortFilterProxyModel *mPluginsProxyModel; - QItemSelectionModel *mPluginsSelectModel; + + QTableView *mMastersTable; + QTableView *mPluginsTable; QToolBar *mProfileToolBar; QMenu *mContextMenu; QAction *mNewProfileAction; - QAction *mCopyProfileAction; QAction *mDeleteProfileAction; - QAction *mMoveUpAction; - QAction *mMoveDownAction; - QAction *mMoveTopAction; - QAction *mMoveBottomAction; +// QAction *mMoveUpAction; +// QAction *mMoveDownAction; +// QAction *mMoveTopAction; +// QAction *mMoveBottomAction; QAction *mCheckAction; QAction *mUncheckAction; @@ -86,17 +78,12 @@ private: QSettings *mLauncherConfig; - const QStringList checkedPlugins(); - const QStringList selectedMasters(); +// const QStringList checkedPlugins(); +// const QStringList selectedMasters(); - void addDataFiles(Files::Collections &fileCollections, const QString &encoding); - void addPlugins(const QModelIndex &index); - void removePlugins(const QModelIndex &index); - void uncheckPlugins(); void createActions(); void setupConfig(); void readConfig(); - void scrollToSelection(); }; diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index be89902c8c..f009c3df00 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -2,7 +2,7 @@ #include <QFileInfo> #include <QDir> -#include <components/esm/esm_reader.hpp> +#include <components/esm/esmreader.hpp> #include "esm/esmfile.hpp" From 68a856ff6fe8f86a7de123e69eaf4061e1764828 Mon Sep 17 00:00:00 2001 From: cfcohen <cfcohen@verizon.net> Date: Wed, 10 Oct 2012 22:00:44 -0400 Subject: [PATCH 031/255] Human readable labels for many records types. Human readable flags for many record types. Improved DialInfo rule parsing. Discovered several issues involving the assignment of various flag bits. --- apps/esmtool/CMakeLists.txt | 2 + apps/esmtool/labels.cpp | 884 ++++++++++++++++++++++++++++++++++++ apps/esmtool/labels.hpp | 64 +++ apps/esmtool/record.cpp | 313 +++++++++---- 4 files changed, 1162 insertions(+), 101 deletions(-) create mode 100644 apps/esmtool/labels.cpp create mode 100644 apps/esmtool/labels.hpp diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index f48aa41bf8..5c588fb296 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -1,5 +1,7 @@ set(ESMTOOL esmtool.cpp + labels.hpp + labels.cpp record.hpp record.cpp ) diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp new file mode 100644 index 0000000000..1ebed1d551 --- /dev/null +++ b/apps/esmtool/labels.cpp @@ -0,0 +1,884 @@ +#include "labels.hpp" + +#include <components/esm/loadbody.hpp> +#include <components/esm/loadcell.hpp> +#include <components/esm/loadcont.hpp> +#include <components/esm/loadcrea.hpp> +#include <components/esm/loadlevlist.hpp> +#include <components/esm/loadligh.hpp> +#include <components/esm/loadmgef.hpp> +#include <components/esm/loadnpc.hpp> +#include <components/esm/loadrace.hpp> +#include <components/esm/loadspel.hpp> +#include <components/esm/loadweap.hpp> +#include <components/esm/aipackage.hpp> + +#include <iostream> +#include <boost/format.hpp> + +std::string bodyPartLabel(char idx) +{ + const char *bodyPartLabels[] = { + "Head", + "Hair", + "Neck", + "Cuirass", + "Groin", + "Skirt", + "Right Hand", + "Left Hand", + "Right Wrist", + "Left Wrist", + "Shield", + "Right Forearm", + "Left Forearm", + "Right Upperarm", + "Left Upperarm", + "Right Foot", + "Left Foot", + "Right Ankle", + "Left Ankle", + "Right Knee", + "Left Knee", + "Right Leg", + "Left Leg", + "Right Shoulder", + "Left Shoulder", + "Weapon", + "Tail" + }; + + // BUG? idx should probably be unsigned char instead + if ((int)idx >= 0 && (int)(idx) <= 26) + return bodyPartLabels[(int)(idx)]; + else + return "Invalid"; +} + +std::string meshPartLabel(char idx) +{ + const char *meshPartLabels[] = { + "Head", + "Hair", + "Neck", + "Chest", + "Groin", + "Hand", + "Wrist", + "Forearm", + "Upperarm", + "Foot", + "Ankle", + "Knee", + "Upper Leg", + "Clavicle", + "Tail" + }; + + if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MP_Tail) + return meshPartLabels[(int)(idx)]; + else + return "Invalid"; +} + +std::string meshTypeLabel(char idx) +{ + const char *meshTypeLabels[] = { + "Skin", + "Clothing", + "Armor" + }; + + if ((int)(idx) >= 0 && (int)(idx) <= ESM::BodyPart::MT_Armor) + return meshTypeLabels[(int)(idx)]; + else + return "Invalid"; +} + +std::string clothingTypeLabel(int idx) +{ + const char *clothingTypeLabels[] = { + "Pants", + "Shoes", + "Shirt", + "Belt", + "Robe", + "Right Glove", + "Left Glove", + "Skirt", + "Ring", + "Amulet" + }; + + if (idx >= 0 && idx <= 9) + return clothingTypeLabels[idx]; + else + return "Invalid"; +} + +std::string armorTypeLabel(int idx) +{ + const char *armorTypeLabels[] = { + "Helmet", + "Cuirass", + "Left Pauldron", + "Right Pauldron", + "Greaves", + "Boots", + "Left Gauntlet", + "Right Gauntlet", + "Shield", + "Left Bracer", + "Right Bracer" + }; + + if (idx >= 0 && idx <= 10) + return armorTypeLabels[idx]; + else + return "Invalid"; +} + +std::string dialogTypeLabel(int idx) +{ + const char *dialogTypeLabels[] = { + "Topic", + "Voice", + "Greeting", + "Persuasion", + "Journal" + }; + + if (idx >= 0 && idx <= 4) + return dialogTypeLabels[idx]; + else if (idx == -1) + return "Deleted"; + else + return "Invalid"; +} + +std::string questStatusLabel(int idx) +{ + const char *questStatusLabels[] = { + "None", + "Name", + "Finished", + "Restart", + "Deleted" + }; + + if (idx >= 0 && idx <= 4) + return questStatusLabels[idx]; + else + return "Invalid"; +} + +std::string creatureTypeLabel(int idx) +{ + const char *creatureTypeLabels[] = { + "Creature", + "Daedra", + "Undead", + "Humanoid", + }; + + if (idx >= 0 && idx <= 3) + return creatureTypeLabels[idx]; + else + return "Invalid"; +} + +std::string soundTypeLabel(int idx) +{ + const char *soundTypeLabels[] = { + "Left Foot", + "Right Foot", + "Swim Left", + "Swim Right", + "Moan", + "Roar", + "Scream", + "Land" + }; + + if (idx >= 0 && idx <= 7) + return soundTypeLabels[idx]; + else + return "Invalid"; +} + +std::string weaponTypeLabel(int idx) +{ + const char *weaponTypeLabels[] = { + "Short Blade One Hand", + "Long Blade One Hand", + "Long Blade Two Hand", + "Blunt One Hand", + "Blunt Two Close", + "Blunt Two Wide", + "Spear Two Wide", + "Axe One Hand", + "Axe Two Hand", + "Marksman Bow", + "Marksman Crossbow", + "Marksman Thrown", + "Arrow", + "Bolt" + }; + + if (idx >= 0 && idx <= 13) + return weaponTypeLabels[idx]; + else + return "Invalid"; +} + +std::string aiTypeLabel(int type) +{ + if (type == ESM::AI_Wander) return "Wander"; + else if (type == ESM::AI_Travel) return "Travel"; + else if (type == ESM::AI_Follow) return "Follow"; + else if (type == ESM::AI_Escort) return "Escort"; + else if (type == ESM::AI_Activate) return "Activate"; + else return "Invalid"; +} + +std::string magicEffectLabel(int idx) +{ + const char* magicEffectLabels [] = { + "Water Breathing", + "Swift Swim", + "Water Walking", + "Shield", + "Fire Shield", + "Lightning Shield", + "Frost Shield", + "Burden", + "Feather", + "Jump", + "Levitate", + "SlowFall", + "Lock", + "Open", + "Fire Damage", + "Shock Damage", + "Frost Damage", + "Drain Attribute", + "Drain Health", + "Drain Magicka", + "Drain Fatigue", + "Drain Skill", + "Damage Attribute", + "Damage Health", + "Damage Magicka", + "Damage Fatigue", + "Damage Skill", + "Poison", + "Weakness to Fire", + "Weakness to Frost", + "Weakness to Shock", + "Weakness to Magicka", + "Weakness to Common Disease", + "Weakness to Blight Disease", + "Weakness to Corprus Disease", + "Weakness to Poison", + "Weakness to Normal Weapons", + "Disintegrate Weapon", + "Disintegrate Armor", + "Invisibility", + "Chameleon", + "Light", + "Sanctuary", + "Night Eye", + "Charm", + "Paralyze", + "Silence", + "Blind", + "Sound", + "Calm Humanoid", + "Calm Creature", + "Frenzy Humanoid", + "Frenzy Creature", + "Demoralize Humanoid", + "Demoralize Creature", + "Rally Humanoid", + "Rally Creature", + "Dispel", + "Soultrap", + "Telekinesis", + "Mark", + "Recall", + "Divine Intervention", + "Almsivi Intervention", + "Detect Animal", + "Detect Enchantment", + "Detect Key", + "Spell Absorption", + "Reflect", + "Cure Common Disease", + "Cure Blight Disease", + "Cure Corprus Disease", + "Cure Poison", + "Cure Paralyzation", + "Restore Attribute", + "Restore Health", + "Restore Magicka", + "Restore Fatigue", + "Restore Skill", + "Fortify Attribute", + "Fortify Health", + "Fortify Magicka", + "Fortify Fatigue", + "Fortify Skill", + "Fortify Maximum Magicka", + "Absorb Attribute", + "Absorb Health", + "Absorb Magicka", + "Absorb Fatigue", + "Absorb Skill", + "Resist Fire", + "Resist Frost", + "Resist Shock", + "Resist Magicka", + "Resist Common Disease", + "Resist Blight Disease", + "Resist Corprus Disease", + "Resist Poison", + "Resist Normal Weapons", + "Resist Paralysis", + "Remove Curse", + "Turn Undead", + "Summon Scamp", + "Summon Clannfear", + "Summon Daedroth", + "Summon Dremora", + "Summon Ancestral Ghost", + "Summon Skeletal Minion", + "Summon Bonewalker", + "Summon Greater Bonewalker", + "Summon Bonelord", + "Summon Winged Twilight", + "Summon Hunger", + "Summon Golden Saint", + "Summon Flame Atronach", + "Summon Frost Atronach", + "Summon Storm Atronach", + "Fortify Attack", + "Command Creature", + "Command Humanoid", + "Bound Dagger", + "Bound Longsword", + "Bound Mace", + "Bound Battle Axe", + "Bound Spear", + "Bound Longbow", + "EXTRA SPELL", + "Bound Cuirass", + "Bound Helm", + "Bound Boots", + "Bound Shield", + "Bound Gloves", + "Corprus", + "Vampirism", + "Summon Centurion Sphere", + "Sun Damage", + "Stunted Magicka", + "Summon Fabricant", + "sEffectSummonCreature01", + "sEffectSummonCreature02", + "sEffectSummonCreature03", + "sEffectSummonCreature04", + "sEffectSummonCreature05" + }; + if (idx >= 0 && idx <= 143) + return magicEffectLabels[idx]; + else + return "Invalid"; +} + +std::string attributeLabel(int idx) +{ + const char* attributeLabels [] = { + "Strength", + "Intelligence", + "Willpower", + "Agility", + "Speed", + "Endurance", + "Personality", + "Luck" + }; + if (idx >= 0 && idx <= 7) + return attributeLabels[idx]; + else + return "Invalid"; +} + +std::string spellTypeLabel(int idx) +{ + const char* spellTypeLabels [] = { + "Spells", + "Abilities", + "Blight Disease", + "Disease", + "Curse", + "Powers" + }; + if (idx >= 0 && idx <= 5) + return spellTypeLabels[idx]; + else + return "Invalid"; +} + +std::string specializationLabel(int idx) +{ + const char* specializationLabels [] = { + "Combat", + "Magic", + "Stealth" + }; + if (idx >= 0 && idx <= 2) + return specializationLabels[idx]; + else + return "Invalid"; +} + +std::string skillLabel(int idx) +{ + const char* skillLabels [] = { + "Block", + "Armorer", + "Medium Armor", + "Heavy Armor", + "Blunt Weapon", + "Long Blade", + "Axe", + "Spear", + "Athletics", + "Enchant", + "Destruction", + "Alteration", + "Illusion", + "Conjuration", + "Mysticism", + "Restoration", + "Alchemy", + "Unarmored", + "Security", + "Sneak", + "Acrobatics", + "Light Armor", + "Short Blade", + "Marksman", + "Mercantile", + "Speechcraft", + "Hand-to-hand" + }; + if (idx >= 0 && idx <= 27) + return skillLabels[idx]; + else + return "Invalid"; +} + +std::string apparatusTypeLabel(int idx) +{ + const char* apparatusTypeLabels [] = { + "Mortar", + "Alembic", + "Calcinator", + "Retort", + }; + if (idx >= 0 && idx <= 3) + return apparatusTypeLabels[idx]; + else + return "Invalid"; +} + +std::string rangeTypeLabel(int idx) +{ + const char* rangeTypeLabels [] = { + "Self", + "Touch", + "Target" + }; + if (idx >= 0 && idx <= 3) + return rangeTypeLabels[idx]; + else + return "Invalid"; +} + +std::string schoolLabel(int idx) +{ + const char* schoolLabels [] = { + "Alteration", + "Conjuration", + "Destruction", + "Illusion", + "Mysticism", + "Restoration" + }; + if (idx >= 0 && idx <= 5) + return schoolLabels[idx]; + else + return "Invalid"; +} + +std::string enchantTypeLabel(int idx) +{ + const char* enchantTypeLabels [] = { + "Cast Once", + "Cast When Strikes", + "Cast When Used", + "Constant Effect" + }; + if (idx >= 0 && idx <= 3) + return enchantTypeLabels[idx]; + else + return "Invalid"; +} + +std::string ruleFunction(int idx) +{ + std::string ruleFunctions[] = { + "Reaction Low", + "Reaction High", + "Rank Requirement", + "NPC? Reputation", + "Health Percent", + "Player Reputation", + "NPC Level", + "Player Health Percent", + "Player Magicka", + "Player Fatigue", + "Player Attribute Strength", + "Player Skill Block", + "Player Skill Armorer", + "Player Skill Medium Armor", + "Player Skill Heavy Armor", + "Player Skill Blunt Weapon", + "Player Skill Long Blade", + "Player Skill Axe", + "Player Skill Spear", + "Player Skill Athletics", + "Player Skill Enchant", + "Player Skill Destruction", + "Player Skill Alteration", + "Player Skill Illusion", + "Player Skill Conjuration", + "Player Skill Mysticism", + "Player SKill Restoration", + "Player Skill Alchemy", + "Player Skill Unarmored", + "Player Skill Security", + "Player Skill Sneak", + "Player Skill Acrobatics", + "Player Skill Light Armor", + "Player Skill Short Blade", + "Player Skill Marksman", + "Player Skill Mercantile", + "Player Skill Speechcraft", + "Player Skill Hand to Hand", +// Unknown1=0->Male, Unknown1=1->Female + "Player Gender", + "Player Expelled from Faction", + "Player Diseased (Common)", + "Player Diseased (Blight)", + "Player Clothing Modifier", + "Player Crime Level", + "Player Same Sex", + "Player Same Race", + "Player Same Faction", + "Faction Rank Difference", + "Player Detected", + "Alarmed", + "Choice Selected", + "Player Attribute Intelligence", + "Player Attribute Willpower", + "Player Attribute Agility", + "Player Attribute Speed", + "Player Attribute Endurance", + "Player Attribute Personality", + "Player Attribute Luck", + "Player Diseased (Corprus)", + "Weather", + "Player is a Vampire", + "Player Level", + "Attacked", + "NPC Talked to Player", + "Player Health", + "Creature Target", + "Friend Hit", + "Fight", + "Hello", + "Alarm", + "Flee", + "Should Attack", + //Unkown but causes NPCs to growl and roar. + "UNKNOWN 72" + }; + if (idx >= 0 && idx <= 72) + return ruleFunctions[idx]; + else + return "Invalid"; +} + +// The "unused flag bits" should probably be defined alongside the +// defined bits in the ESM component. The names of the flag bits are +// very inconsistent. + +std::string bodyPartFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::BodyPart::BPF_Female) properties += "Female "; + if (flags & ESM::BodyPart::BPF_Playable) properties += "Playable "; + int unused = (0xFFFFFFFF ^ + (ESM::BodyPart::BPF_Female| + ESM::BodyPart::BPF_Playable)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string cellFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::Cell::HasWater) properties += "HasWater "; + if (flags & ESM::Cell::Interior) properties += "Interior "; + if (flags & ESM::Cell::NoSleep) properties += "NoSleep "; + if (flags & ESM::Cell::QuasiEx) properties += "QuasiEx "; + // CHANGE? This used value is not in the ESM component. + if (flags & 0x00000040) properties += "Unknown "; + int unused = (0xFFFFFFFF ^ + (ESM::Cell::HasWater| + ESM::Cell::Interior| + ESM::Cell::NoSleep| + ESM::Cell::QuasiEx| + 0x00000040)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string containerFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::Container::Unknown) properties += "Unknown "; + if (flags & ESM::Container::Organic) properties += "Organic "; + if (flags & ESM::Container::Respawn) properties += "Respawn "; + int unused = (0xFFFFFFFF ^ + (ESM::Container::Unknown| + ESM::Container::Organic| + ESM::Container::Respawn)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string creatureFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::Creature::None) properties += "All "; + if (flags & ESM::Creature::Walks) properties += "Walks "; + if (flags & ESM::Creature::Swims) properties += "Swims "; + if (flags & ESM::Creature::Flies) properties += "Flies "; + if (flags & ESM::Creature::Biped) properties += "Biped "; + if (flags & ESM::Creature::Respawn) properties += "Respawn "; + if (flags & ESM::Creature::Weapon) properties += "Weapon "; + if (flags & ESM::Creature::Skeleton) properties += "Skeleton "; + if (flags & ESM::Creature::Metal) properties += "Metal "; + if (flags & ESM::Creature::Essential) properties += "Essential "; + int unused = (0xFFFFFFFF ^ + (ESM::Creature::None| + ESM::Creature::Walks| + ESM::Creature::Swims| + ESM::Creature::Flies| + ESM::Creature::Biped| + ESM::Creature::Respawn| + ESM::Creature::Weapon| + ESM::Creature::Skeleton| + ESM::Creature::Metal| + ESM::Creature::Essential)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string landFlags(int flags) +{ + std::string properties = ""; + // The ESM component says that this first four bits are used, but + // only the first three bits are used as far as I can tell. + // There's also no enumeration of the bit in the ESM component. + if (flags == 0) properties += "[None] "; + if (flags & 0x00000001) properties += "Unknown1 "; + if (flags & 0x00000004) properties += "Unknown3 "; + if (flags & 0x00000002) properties += "Unknown2 "; + if (flags & 0xFFFFFFF8) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string leveledListFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::LeveledListBase::AllLevels) properties += "AllLevels "; + // BUG? This flag apparently not present on creature lists... + if (flags & ESM::LeveledListBase::Each) properties += "Each "; + // BUG! The unsused bits should be defined in LeveledListBase. + int unused = (0xFFFFFFFF ^ + (ESM::LeveledListBase::AllLevels| + ESM::LeveledListBase::Each)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string lightFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::Light::Dynamic) properties += "Dynamic "; + if (flags & ESM::Light::Fire) properties += "Fire "; + if (flags & ESM::Light::Carry) properties += "Carry "; + if (flags & ESM::Light::Flicker) properties += "Flicker "; + if (flags & ESM::Light::FlickerSlow) properties += "FlickerSlow "; + if (flags & ESM::Light::Pulse) properties += "Pulse "; + if (flags & ESM::Light::PulseSlow) properties += "PulseSlow "; + if (flags & ESM::Light::Negative) properties += "Negative "; + if (flags & ESM::Light::OffDefault) properties += "OffDefault "; + int unused = (0xFFFFFFFF ^ + (ESM::Light::Dynamic| + ESM::Light::Fire| + ESM::Light::Carry| + ESM::Light::Flicker| + ESM::Light::FlickerSlow| + ESM::Light::Pulse| + ESM::Light::PulseSlow| + ESM::Light::Negative| + ESM::Light::OffDefault)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string magicEffectFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + // Enchanting & SpellMaking occur on the same list of effects. + // "EXTRA SPELL" appears in the construction set under both the + // spell making and enchanting tabs as an allowed effect. Since + // most of the effects without this flags are defective in various + // ways, it's still very unclear what these flag bits are. + if (flags & ESM::MagicEffect::SpellMaking) properties += "SpellMaking "; + if (flags & ESM::MagicEffect::Enchanting) properties += "Enchanting "; + if (flags & 0x00000040) properties += "RangeNoSelf "; + if (flags & 0x00000080) properties += "RangeTouch "; + if (flags & 0x00000100) properties += "RangeTarget "; + if (flags & 0x00001000) properties += "Unknown2 "; + if (flags & 0x00000001) properties += "AffectSkill "; + if (flags & 0x00000002) properties += "AffectAttribute "; + if (flags & ESM::MagicEffect::NoDuration) properties += "NoDuration "; + if (flags & 0x00000008) properties += "NoMagnitude "; + if (flags & 0x00000010) properties += "Negative "; + if (flags & 0x00000020) properties += "Unknown1 "; + // ESM componet says 0x800 is negative, but none of the magic + // effects have this flags set. + if (flags & ESM::MagicEffect::Negative) properties += "Unused "; + // Since only Chameleon has this flag it could be anything + // that uniquely distinguishes Chameleon. + if (flags & 0x00002000) properties += "Chameleon "; + if (flags & 0x00004000) properties += "Bound "; + if (flags & 0x00008000) properties += "Summon "; + // Calm, Demoralize, Frenzy, Lock, Open, Rally, Soultrap, Turn Unded + if (flags & 0x00010000) properties += "Unknown3 "; + if (flags & 0x00020000) properties += "Absorb "; + if (flags & 0xFFFC0000) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string npcFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + // Mythicmods and the ESM component differ. Mythicmods says + // 0x8=None and 0x10=AutoCalc, while our code defines 0x8 as + // AutoCalc. The former seems to be correct. All Bethesda + // records have bit 0x8 set. A suspiciously large portion of + // females have autocalc turned off. + if (flags & ESM::NPC::Autocalc) properties += "Unknown "; + if (flags & 0x00000010) properties += "Autocalc "; + if (flags & ESM::NPC::Female) properties += "Female "; + if (flags & ESM::NPC::Respawn) properties += "Respawn "; + if (flags & ESM::NPC::Essential) properties += "Essential "; + // These two flags do not appear on any NPCs and may have been + // confused with the flags for creatures. + if (flags & ESM::NPC::Skeleton) properties += "Skeleton "; + if (flags & ESM::NPC::Metal) properties += "Metal "; + // Whether corpses persist is a bit that is unaccounted for, + // however the only unknown bit occurs on ALL records, and + // relatively few NPCs have this bit set. + int unused = (0xFFFFFFFF ^ + (ESM::NPC::Autocalc| + 0x00000010| + ESM::NPC::Female| + ESM::NPC::Respawn| + ESM::NPC::Essential| + ESM::NPC::Skeleton| + ESM::NPC::Metal)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string raceFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + // All races have the playable flag set in Bethesda files. + if (flags & ESM::Race::Playable) properties += "Playable "; + if (flags & ESM::Race::Beast) properties += "Beast "; + int unused = (0xFFFFFFFF ^ + (ESM::Race::Playable| + ESM::Race::Beast)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string spellFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + if (flags & ESM::Spell::F_Autocalc) properties += "Autocalc "; + if (flags & ESM::Spell::F_PCStart) properties += "PCStart "; + if (flags & ESM::Spell::F_Always) properties += "Always "; + int unused = (0xFFFFFFFF ^ + (ESM::Spell::F_Autocalc| + ESM::Spell::F_PCStart| + ESM::Spell::F_Always)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} + +std::string weaponFlags(int flags) +{ + std::string properties = ""; + if (flags == 0) properties += "[None] "; + // The interpretation of the flags are still unclear to me. + // Apparently you can't be Silver without being Magical? Many of + // the "Magical" weapons don't have enchantments of any sort. + if (flags & ESM::Weapon::Magical) properties += "Magical "; + if (flags & ESM::Weapon::Silver) properties += "Silver "; + int unused = (0xFFFFFFFF ^ + (ESM::Weapon::Magical| + ESM::Weapon::Silver)); + if (flags & unused) properties += "Invalid "; + properties += str(boost::format("(0x%08X)") % flags); + return properties; +} diff --git a/apps/esmtool/labels.hpp b/apps/esmtool/labels.hpp new file mode 100644 index 0000000000..7f1ff79865 --- /dev/null +++ b/apps/esmtool/labels.hpp @@ -0,0 +1,64 @@ +#ifndef OPENMW_ESMTOOL_LABELS_H +#define OPENMW_ESMTOOL_LABELS_H + +#include <string> + +std::string bodyPartLabel(char idx); +std::string meshPartLabel(char idx); +std::string meshTypeLabel(char idx); +std::string clothingTypeLabel(int idx); +std::string armorTypeLabel(int idx); +std::string dialogTypeLabel(int idx); +std::string questStatusLabel(int idx); +std::string creatureTypeLabel(int idx); +std::string soundTypeLabel(int idx); +std::string weaponTypeLabel(int idx); + +// This function's a bit different because the types are record types, +// not consecutive values. +std::string aiTypeLabel(int type); + +// This one's also a bit different, because it enumerates dialog +// select rule functions, not types. Structurally, it still converts +// indexes to strings for display. +std::string ruleFunction(int idx); + +// The labels below here can all be loaded from GMSTs, but are not +// currently because among other things, that requires loading the +// GMSTs before dumping any of the records. + +// If the data format supported ordered lists of GMSTs (post 1.0), the +// lists could define the valid values, their localization strings, +// and the indexes for referencing the types in other records in the +// database. Then a single label function could work for all types. + +std::string magicEffectLabel(int idx); +std::string attributeLabel(int idx); +std::string spellTypeLabel(int idx); +std::string specializationLabel(int idx); +std::string skillLabel(int idx); +std::string apparatusTypeLabel(int idx); +std::string rangeTypeLabel(int idx); +std::string schoolLabel(int idx); +std::string enchantTypeLabel(int idx); + +// The are the flag functions that convert a bitmask into a list of +// human readble strings representing the set bits. + +std::string bodyPartFlags(int flags); +std::string cellFlags(int flags); +std::string containerFlags(int flags); +std::string creatureFlags(int flags); +std::string landFlags(int flags); +std::string leveledListFlags(int flags); +std::string lightFlags(int flags); +std::string magicEffectFlags(int flags); +std::string npcFlags(int flags); +std::string raceFlags(int flags); +std::string spellFlags(int flags); +std::string weaponFlags(int flags); + +// Missing flags functions: +// aiServicesFlags, possibly more + +#endif diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index c679a1c4df..856700f5e3 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -1,54 +1,126 @@ #include "record.hpp" +#include "labels.hpp" #include <iostream> #include <boost/format.hpp> void printAIPackage(ESM::AIPackage p) { - if (p.mType == ESM::AI_Wander) - { - std::cout << " AIType Wander:" << std::endl; - std::cout << " Distance: " << p.mWander.mDistance << std::endl; - std::cout << " Duration: " << p.mWander.mDuration << std::endl; - std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl; - if (p.mWander.mUnk != 1) - std::cout << " Unknown: " << (int)p.mWander.mUnk << std::endl; + std::cout << " AI Type: " << aiTypeLabel(p.mType) + << " (" << boost::format("0x%08X") % p.mType << ")" << std::endl; + if (p.mType == ESM::AI_Wander) + { + std::cout << " Distance: " << p.mWander.mDistance << std::endl; + std::cout << " Duration: " << p.mWander.mDuration << std::endl; + std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl; + if (p.mWander.mUnk != 1) + std::cout << " Unknown: " << (int)p.mWander.mUnk << std::endl; + + std::cout << " Idle: "; + for (int i = 0; i != 8; i++) + std::cout << (int)p.mWander.mIdle[i] << " "; + std::cout << std::endl; + } + else if (p.mType == ESM::AI_Travel) + { + std::cout << " Travel Coordinates: (" << p.mTravel.mX << "," + << p.mTravel.mY << "," << p.mTravel.mZ << ")" << std::endl; + std::cout << " Travel Unknown: " << (int)p.mTravel.mUnk << std::endl; + } + else if (p.mType == ESM::AI_Follow || p.mType == ESM::AI_Escort) + { + std::cout << " Follow Coordinates: (" << p.mTarget.mX << "," + << p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl; + std::cout << " Duration: " << p.mTarget.mDuration << std::endl; + std::cout << " Target ID: " << p.mTarget.mId.toString() << std::endl; + std::cout << " Unknown: " << (int)p.mTarget.mUnk << std::endl; + } + else if (p.mType == ESM::AI_Activate) + { + std::cout << " Name: " << p.mActivate.mName.toString() << std::endl; + std::cout << " Activate Unknown: " << (int)p.mActivate.mUnk << std::endl; + } + else { + std::cout << " BadPackage: " << boost::format("0x%08x") % p.mType << std::endl; + } + + if (p.mCellName != "") + std::cout << " Cell Name: " << p.mCellName << std::endl; +} - std::cout << " Idle: "; - for (int i = 0; i != 8; i++) - std::cout << (int)p.mWander.mIdle[i] << " "; - std::cout << std::endl; - } - else if (p.mType == ESM::AI_Travel) - { - std::cout << " AIType Travel:" << std::endl; - std::cout << " Travel Coordinates: (" << p.mTravel.mX << "," - << p.mTravel.mY << "," << p.mTravel.mZ << ")" << std::endl; - std::cout << " Travel Unknown: " << (int)p.mTravel.mUnk << std::endl; - } - else if (p.mType == ESM::AI_Follow || p.mType == ESM::AI_Escort) - { - if (p.mType == ESM::AI_Follow) std::cout << " AIType Follow:" << std::endl; - else std::cout << " AIType Escort:" << std::endl; +std::string ruleString(ESM::DialInfo::SelectStruct ss) +{ + std::string rule = ss.mSelectRule; + + if (rule.length() < 5) + return "INVALID"; + + char type = rule[1]; + char indicator = rule[2]; + + std::string type_str = "INVALID"; + std::string func_str = str(boost::format("INVALID=%s") % rule.substr(1,3)); + int func; + std::istringstream iss(rule.substr(2,2)); + iss >> func; - std::cout << " Follow Coordinates: (" << p.mTarget.mX << "," - << p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl; - std::cout << " Duration: " << p.mTarget.mDuration << std::endl; - std::cout << " Target ID: " << p.mTarget.mId.toString() << std::endl; - std::cout << " Unknown: " << (int)p.mTarget.mUnk << std::endl; - } - else if (p.mType == ESM::AI_Activate) - { - std::cout << " AIType Activate:" << std::endl; - std::cout << " Name: " << p.mActivate.mName.toString() << std::endl; - std::cout << " Activate Unknown: " << (int)p.mActivate.mUnk << std::endl; - } - else { - std::cout << " BadPackage: " << boost::format("0x%08x") % p.mType << std::endl; - } + switch(type) + { + case '1': + type_str = "Function"; + func_str = ruleFunction(func); + break; + case '2': + if (indicator == 's') type_str = "Global short"; + else if (indicator == 'l') type_str = "Global long"; + else if (indicator == 'f') type_str = "Global float"; + break; + case '3': + if (indicator == 's') type_str = "Local short"; + else if (indicator == 'l') type_str = "Local long"; + else if (indicator == 'f') type_str = "Local float"; + break; + case '4': if (indicator == 'J') type_str = "Journal"; break; + case '5': if (indicator == 'I') type_str = "Item type"; break; + case '6': if (indicator == 'D') type_str = "NPC Dead"; break; + case '7': if (indicator == 'X') type_str = "Not ID"; break; + case '8': if (indicator == 'F') type_str = "Not Faction"; break; + case '9': if (indicator == 'C') type_str = "Not Class"; break; + case 'A': if (indicator == 'R') type_str = "Not Race"; break; + case 'B': if (indicator == 'L') type_str = "Not Cell"; break; + case 'C': if (indicator == 's') type_str = "Not Local"; break; + } + + // Append the variable name to the function string if any. + if (type != '1') func_str = rule.substr(5); + + // In the previous switch, we assumed that the second char was X + // for all types not qual to one. If this wasn't true, go back to + // the error message. + if (type != '1' && rule[3] != 'X') + func_str = str(boost::format("INVALID=%s") % rule.substr(1,3)); - if (p.mCellName != "") - std::cout << " Cell Name: " << p.mCellName << std::endl; + char oper = rule[4]; + std::string oper_str = "??"; + switch (oper) + { + case '0': oper_str = "=="; break; + case '1': oper_str = "!="; break; + case '2': oper_str = "< "; break; + case '3': oper_str = "<="; break; + case '4': oper_str = "> "; break; + case '5': oper_str = ">="; break; + } + + std::string value_str = "??"; + if (ss.mType == ESM::VT_Int) + value_str = str(boost::format("%d") % ss.mI); + else if (ss.mType == ESM::VT_Float) + value_str = str(boost::format("%f") % ss.mF); + + std::string result = str(boost::format("%-12s %-32s %2s %s") + % type_str % func_str % oper_str % value_str); + return result; } void printEffectList(ESM::EffectList effects) @@ -57,12 +129,16 @@ void printEffectList(ESM::EffectList effects) std::vector<ESM::ENAMstruct>::iterator eit; for (eit = effects.mList.begin(); eit != effects.mList.end(); eit++) { - std::cout << " Effect[" << i << "]: " << eit->mEffectID << std::endl; + std::cout << " Effect[" << i << "]: " << magicEffectLabel(eit->mEffectID) + << " (" << eit->mEffectID << ")" << std::endl; if (eit->mSkill != -1) - std::cout << " Skill: " << (int)eit->mSkill << std::endl; + std::cout << " Skill: " << skillLabel(eit->mSkill) + << " (" << (int)eit->mSkill << ")" << std::endl; if (eit->mAttribute != -1) - std::cout << " Attribute: " << (int)eit->mAttribute << std::endl; - std::cout << " Range: " << eit->mRange << std::endl; + std::cout << " Attribute: " << attributeLabel(eit->mAttribute) + << " (" << (int)eit->mAttribute << ")" << std::endl; + std::cout << " Range: " << rangeTypeLabel(eit->mRange) + << " (" << eit->mRange << ")" << std::endl; // Area is always zero if range type is "Self" if (eit->mRange != ESM::RT_Self) std::cout << " Area: " << eit->mArea << std::endl; @@ -331,7 +407,8 @@ void Record<ESM::Armor>::print() std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") std::cout << " Enchantment: " << mData.mEnchant << std::endl; - std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Type: " << armorTypeLabel(mData.mData.mType) + << " (" << mData.mData.mType << ")" << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Health: " << mData.mData.mHealth << std::endl; @@ -340,7 +417,8 @@ void Record<ESM::Armor>::print() std::vector<ESM::PartReference>::iterator pit; for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++) { - std::cout << " Body Part: " << (int)(pit->mPart) << std::endl; + std::cout << " Body Part: " << bodyPartLabel(pit->mPart) + << " (" << (int)(pit->mPart) << ")" << std::endl; std::cout << " Male Name: " << pit->mMale << std::endl; if (pit->mFemale != "") std::cout << " Female Name: " << pit->mFemale << std::endl; @@ -354,7 +432,8 @@ void Record<ESM::Apparatus>::print() std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; std::cout << " Script: " << mData.mScript << std::endl; - std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Type: " << apparatusTypeLabel(mData.mData.mType) + << " (" << (int)mData.mData.mType << ")" << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Quality: " << mData.mData.mQuality << std::endl; @@ -365,9 +444,11 @@ void Record<ESM::BodyPart>::print() { std::cout << " Name: " << mData.mName << std::endl; std::cout << " Model: " << mData.mModel << std::endl; - std::cout << " Type: " << (int)mData.mData.mType << std::endl; - std::cout << " Flags: " << (int)mData.mData.mFlags << std::endl; - std::cout << " Part: " << (int)mData.mData.mPart << std::endl; + std::cout << " Type: " << meshTypeLabel(mData.mData.mType) + << " (" << (int)mData.mData.mType << ")" << std::endl; + std::cout << " Flags: " << bodyPartFlags(mData.mData.mFlags) << std::endl; + std::cout << " Part: " << meshPartLabel(mData.mData.mPart) + << " (" << (int)mData.mData.mPart << ")" << std::endl; std::cout << " Vampire: " << (int)mData.mData.mVampire << std::endl; } @@ -413,7 +494,7 @@ void Record<ESM::Cell>::print() std::cout << " Name: " << mData.mName << std::endl; if (mData.mRegion != "") std::cout << " Region: " << mData.mRegion << std::endl; - std::cout << " Flags: " << (int)mData.mData.mFlags << std::endl; + std::cout << " Flags: " << cellFlags(mData.mData.mFlags) << std::endl; std::cout << " Coordinates: " << " (" << mData.getGridX() << "," << mData.getGridY() << ")" << std::endl; @@ -441,13 +522,18 @@ void Record<ESM::Class>::print() std::cout << " Description: " << mData.mDescription << std::endl; std::cout << " Playable: " << mData.mData.mIsPlayable << std::endl; std::cout << " AutoCalc: " << mData.mData.mCalc << std::endl; - std::cout << " Attribute1: " << mData.mData.mAttribute[0] << std::endl; - std::cout << " Attribute2: " << mData.mData.mAttribute[1] << std::endl; - std::cout << " Specialization: " << mData.mData.mSpecialization << std::endl; + std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute[0]) + << " (" << mData.mData.mAttribute[0] << ")" << std::endl; + std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute[1]) + << " (" << mData.mData.mAttribute[1] << ")" << std::endl; + std::cout << " Specialization: " << specializationLabel(mData.mData.mSpecialization) + << " (" << mData.mData.mSpecialization << ")" << std::endl; for (int i = 0; i != 5; i++) - std::cout << " Major Skill: " << mData.mData.mSkills[i][0] << std::endl; + std::cout << " Major Skill: " << skillLabel(mData.mData.mSkills[i][0]) + << " (" << mData.mData.mSkills[i][0] << ")" << std::endl; for (int i = 0; i != 5; i++) - std::cout << " Minor Skill: " << mData.mData.mSkills[i][1] << std::endl; + std::cout << " Minor Skill: " << skillLabel(mData.mData.mSkills[i][1]) + << " (" << mData.mData.mSkills[i][1] << ")" << std::endl; } template<> @@ -460,10 +546,20 @@ void Record<ESM::Clothing>::print() std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") std::cout << " Enchantment: " << mData.mEnchant << std::endl; - std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Type: " << clothingTypeLabel(mData.mData.mType) + << " (" << mData.mData.mType << ")" << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; - // mEnchant also in CTDTstruct? + std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; + std::vector<ESM::PartReference>::iterator pit; + for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++) + { + std::cout << " Body Part: " << bodyPartLabel(pit->mPart) + << " (" << (int)(pit->mPart) << ")" << std::endl; + std::cout << " Male Name: " << pit->mMale << std::endl; + if (pit->mFemale != "") + std::cout << " Female Name: " << pit->mFemale << std::endl; + } } template<> @@ -473,7 +569,7 @@ void Record<ESM::Container>::print() std::cout << " Model: " << mData.mModel << std::endl; if (mData.mScript != "") std::cout << " Script: " << mData.mScript << std::endl; - std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Flags: " << containerFlags(mData.mFlags) << std::endl; std::cout << " Weight: " << mData.mWeight << std::endl; std::vector<ESM::ContItem>::iterator cit; for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) @@ -487,11 +583,12 @@ void Record<ESM::Creature>::print() std::cout << " Name: " << mData.mName << std::endl; std::cout << " Model: " << mData.mModel << std::endl; std::cout << " Script: " << mData.mScript << std::endl; - std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Flags: " << creatureFlags(mData.mFlags) << std::endl; std::cout << " Original: " << mData.mOriginal << std::endl; std::cout << " Scale: " << mData.mScale << std::endl; - std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Type: " << creatureTypeLabel(mData.mData.mType) + << " (" << mData.mData.mType << ")" << std::endl; std::cout << " Level: " << mData.mData.mLevel << std::endl; std::cout << " Attributes:" << std::endl; @@ -547,7 +644,8 @@ void Record<ESM::Creature>::print() template<> void Record<ESM::Dialogue>::print() { - std::cout << " Type: " << (int)mData.mType << std::endl; + std::cout << " Type: " << dialogTypeLabel(mData.mType) + << " (" << (int)mData.mType << ")" << std::endl; // Sadly, there are no DialInfos, because the loader dumps as it // loads, rather than loading and then dumping. :-( Anyone mind if // I change this? @@ -569,7 +667,8 @@ void Record<ESM::Door>::print() template<> void Record<ESM::Enchantment>::print() { - std::cout << " Type: " << mData.mData.mType << std::endl; + std::cout << " Type: " << enchantTypeLabel(mData.mData.mType) + << " (" << mData.mData.mType << ")" << std::endl; std::cout << " Cost: " << mData.mData.mCost << std::endl; std::cout << " Charge: " << mData.mData.mCharge << std::endl; std::cout << " AutoCalc: " << mData.mData.mAutocalc << std::endl; @@ -583,11 +682,14 @@ void Record<ESM::Faction>::print() std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl; if (mData.mData.mUnknown != -1) std::cout << " Unknown: " << mData.mData.mUnknown << std::endl; - std::cout << " Attribute1: " << mData.mData.mAttribute1 << std::endl; - std::cout << " Attribute2: " << mData.mData.mAttribute2 << std::endl; + std::cout << " Attribute1: " << attributeLabel(mData.mData.mAttribute1) + << " (" << mData.mData.mAttribute1 << ")" << std::endl; + std::cout << " Attribute2: " << attributeLabel(mData.mData.mAttribute2) + << " (" << mData.mData.mAttribute2 << ")" << std::endl; for (int i = 0; i != 6; i++) if (mData.mData.mSkillID[i] != -1) - std::cout << " Skill: " << mData.mData.mSkillID[i] << std::endl; + std::cout << " Skill: " << skillLabel(mData.mData.mSkillID[i]) + << " (" << mData.mData.mSkillID[i] << ")" << std::endl; for (int i = 0; i != 10; i++) if (mData.mRanks[i] != "") { @@ -683,13 +785,14 @@ void Record<ESM::DialInfo>::print() // std::cout << "-------------------------------------------" << std::endl; } - std::cout << " Quest Status: " << mData.mQuestStatus << std::endl; + std::cout << " Quest Status: " << questStatusLabel(mData.mQuestStatus) + << " (" << mData.mQuestStatus << ")" << std::endl; std::cout << " Unknown1: " << mData.mData.mUnknown1 << std::endl; std::cout << " Unknown2: " << (int)mData.mData.mUnknown2 << std::endl; std::vector<ESM::DialInfo::SelectStruct>::iterator sit; for (sit = mData.mSelects.begin(); sit != mData.mSelects.end(); sit++) - std::cout << " Select Rule: " << sit->mType << " " << sit->mSelectRule << std::endl; + std::cout << " Select Rule: " << ruleString(*sit) << std::endl; } template<> @@ -706,9 +809,12 @@ void Record<ESM::Ingredient>::print() { // A value of -1 means no effect if (mData.mData.mEffectID[i] == -1) continue; - std::cout << " Effect: " << mData.mData.mEffectID[i] << std::endl; - std::cout << " Skill: " << mData.mData.mSkills[i] << std::endl; - std::cout << " Attribute: " << mData.mData.mAttributes[i] << std::endl; + std::cout << " Effect: " << magicEffectLabel(mData.mData.mEffectID[i]) + << " (" << mData.mData.mEffectID[i] << ")" << std::endl; + std::cout << " Skill: " << skillLabel(mData.mData.mSkills[i]) + << " (" << mData.mData.mSkills[i] << ")" << std::endl; + std::cout << " Attribute: " << attributeLabel(mData.mData.mAttributes[i]) + << " (" << mData.mData.mAttributes[i] << ")" << std::endl; } } @@ -716,7 +822,7 @@ template<> void Record<ESM::Land>::print() { std::cout << " Coordinates: (" << mData.mX << "," << mData.mY << ")" << std::endl; - std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Flags: " << landFlags(mData.mFlags) << std::endl; std::cout << " HasData: " << mData.mHasData << std::endl; std::cout << " DataTypes: " << mData.mDataTypes << std::endl; @@ -739,7 +845,7 @@ template<> void Record<ESM::CreatureLevList>::print() { std::cout << " Chance for None: " << (int)mData.mChanceNone << std::endl; - std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Flags: " << leveledListFlags(mData.mFlags) << std::endl; std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) @@ -751,7 +857,7 @@ template<> void Record<ESM::ItemLevList>::print() { std::cout << " Chance for None: " << (int)mData.mChanceNone << std::endl; - std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Flags: " << leveledListFlags(mData.mFlags) << std::endl; std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) @@ -770,7 +876,7 @@ void Record<ESM::Light>::print() std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") std::cout << " Script: " << mData.mScript << std::endl; - std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Flags: " << lightFlags(mData.mData.mFlags) << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Sound: " << mData.mSound << std::endl; @@ -802,6 +908,7 @@ void Record<ESM::Probe>::print() std::cout << " Icon: " << mData.mIcon << std::endl; if (mData.mScript != "") std::cout << " Script: " << mData.mScript << std::endl; + // BUG? No Type Label? std::cout << " Type: " << mData.mType << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; @@ -835,10 +942,11 @@ void Record<ESM::LandTexture>::print() template<> void Record<ESM::MagicEffect>::print() { - std::cout << " Index: " << mData.mIndex << std::endl; + std::cout << " Index: " << magicEffectLabel(mData.mIndex) + << " (" << mData.mIndex << ")" << std::endl; std::cout << " Description: " << mData.mDescription << std::endl; std::cout << " Icon: " << mData.mIcon << std::endl; - std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Flags: " << magicEffectFlags(mData.mData.mFlags) << std::endl; std::cout << " Particle Texture: " << mData.mParticle << std::endl; if (mData.mCasting != "") std::cout << " Casting Static: " << mData.mCasting << std::endl; @@ -856,7 +964,8 @@ void Record<ESM::MagicEffect>::print() std::cout << " Area Static: " << mData.mArea << std::endl; if (mData.mAreaSound != "") std::cout << " Area Sound: " << mData.mAreaSound << std::endl; - std::cout << " School: " << mData.mData.mSchool << std::endl; + std::cout << " School: " << schoolLabel(mData.mData.mSchool) + << " (" << mData.mData.mSchool << ")" << std::endl; std::cout << " Base Cost: " << mData.mData.mBaseCost << std::endl; std::cout << " Speed: " << mData.mData.mSpeed << std::endl; std::cout << " Size: " << mData.mData.mSize << std::endl; @@ -893,7 +1002,7 @@ void Record<ESM::NPC>::print() std::cout << " Script: " << mData.mScript << std::endl; if (mData.mFaction != "") std::cout << " Faction: " << mData.mFaction << std::endl; - std::cout << " Flags: " << mData.mFlags << std::endl; + std::cout << " Flags: " << npcFlags(mData.mFlags) << std::endl; // Seriously? if (mData.mNpdt52.mGold == -10) @@ -929,7 +1038,7 @@ void Record<ESM::NPC>::print() std::cout << " Skills:" << std::endl; for (int i = 0; i != 27; i++) - std::cout << " " << i << " = " + std::cout << " " << skillLabel(i) << ": " << (int)((unsigned char)mData.mNpdt52.mSkills[i]) << std::endl; std::cout << " Health: " << mData.mNpdt52.mHealth << std::endl; @@ -1018,7 +1127,7 @@ void Record<ESM::Race>::print() { std::cout << " Name: " << mData.mName << std::endl; std::cout << " Description: " << mData.mDescription << std::endl; - std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Flags: " << raceFlags(mData.mData.mFlags) << std::endl; std::cout << " Male:" << std::endl; std::cout << " Strength: " @@ -1067,8 +1176,10 @@ void Record<ESM::Race>::print() for (int i = 0; i != 7; i++) // Not all races have 7 skills. if (mData.mData.mBonus[i].mSkill != -1) - std::cout << " Skill: " << mData.mData.mBonus[i].mSkill - << " = " << mData.mData.mBonus[i].mBonus << std::endl; + std::cout << " Skill: " + << skillLabel(mData.mData.mBonus[i].mSkill) + << " (" << mData.mData.mBonus[i].mSkill << ") = " + << mData.mData.mBonus[i].mBonus << std::endl; std::vector<std::string>::iterator sit; for (sit = mData.mPowers.mList.begin(); sit != mData.mPowers.mList.end(); sit++) @@ -1130,18 +1241,15 @@ void Record<ESM::Script>::print() template<> void Record<ESM::Skill>::print() { - std::cout << " ID: " << mData.mIndex << std::endl; - - const char *spec = 0; - int specId = mData.mData.mSpecialization; - if (specId == 0) { - spec = "Combat"; - } else if (specId == 1) { - spec = "Magic"; - } else { - spec = "Stealth"; - } - std::cout << " Type: " << spec << std::endl; + std::cout << " ID: " << skillLabel(mData.mIndex) + << " (" << mData.mIndex << ")" << std::endl; + std::cout << " Description: " << mData.mDescription << std::endl; + std::cout << " Governing Attribute: " << attributeLabel(mData.mData.mAttribute) + << " (" << mData.mData.mAttribute << ")" << std::endl; + std::cout << " Specialization: " << specializationLabel(mData.mData.mSpecialization) + << " (" << mData.mData.mSpecialization << ")" << std::endl; + for (int i = 0; i != 4; i++) + std::cout << " UseValue[" << i << "]:" << mData.mData.mUseValue[i] << std::endl; } template<> @@ -1149,7 +1257,8 @@ void Record<ESM::SoundGenerator>::print() { std::cout << " Creature: " << mData.mCreature << std::endl; std::cout << " Sound: " << mData.mSound << std::endl; - std::cout << " Type: " << mData.mType << std::endl; + std::cout << " Type: " << soundTypeLabel(mData.mType) + << " (" << mData.mType << ")" << std::endl; } template<> @@ -1166,8 +1275,9 @@ template<> void Record<ESM::Spell>::print() { std::cout << " Name: " << mData.mName << std::endl; - std::cout << " Type: " << mData.mData.mType << std::endl; - std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Type: " << spellTypeLabel(mData.mData.mType) + << " (" << mData.mData.mType << ")" << std::endl; + std::cout << " Flags: " << spellFlags(mData.mData.mFlags) << std::endl; std::cout << " Cost: " << mData.mData.mCost << std::endl; printEffectList(mData.mEffects); } @@ -1199,8 +1309,9 @@ void Record<ESM::Weapon>::print() std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") std::cout << " Enchantment: " << mData.mEnchant << std::endl; - std::cout << " Type: " << mData.mData.mType << std::endl; - std::cout << " Flags: " << mData.mData.mFlags << std::endl; + std::cout << " Type: " << weaponTypeLabel(mData.mData.mType) + << " (" << mData.mData.mType << ")" << std::endl; + std::cout << " Flags: " << weaponFlags(mData.mData.mFlags) << std::endl; std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Health: " << mData.mData.mHealth << std::endl; From e4a61486c8420606aac580973f088ec141d956fc Mon Sep 17 00:00:00 2001 From: cfcohen <cfcohen@verizon.net> Date: Wed, 10 Oct 2012 22:15:19 -0400 Subject: [PATCH 032/255] Removed minor comments left in by accident. --- apps/esmtool/labels.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/esmtool/labels.cpp b/apps/esmtool/labels.cpp index 1ebed1d551..9fb2332379 100644 --- a/apps/esmtool/labels.cpp +++ b/apps/esmtool/labels.cpp @@ -48,7 +48,6 @@ std::string bodyPartLabel(char idx) "Tail" }; - // BUG? idx should probably be unsigned char instead if ((int)idx >= 0 && (int)(idx) <= 26) return bodyPartLabels[(int)(idx)]; else @@ -576,7 +575,6 @@ std::string ruleFunction(int idx) "Player Skill Mercantile", "Player Skill Speechcraft", "Player Skill Hand to Hand", -// Unknown1=0->Male, Unknown1=1->Female "Player Gender", "Player Expelled from Faction", "Player Diseased (Common)", @@ -646,7 +644,7 @@ std::string cellFlags(int flags) if (flags & ESM::Cell::Interior) properties += "Interior "; if (flags & ESM::Cell::NoSleep) properties += "NoSleep "; if (flags & ESM::Cell::QuasiEx) properties += "QuasiEx "; - // CHANGE? This used value is not in the ESM component. + // This used value is not in the ESM component. if (flags & 0x00000040) properties += "Unknown "; int unused = (0xFFFFFFFF ^ (ESM::Cell::HasWater| @@ -725,9 +723,8 @@ std::string leveledListFlags(int flags) std::string properties = ""; if (flags == 0) properties += "[None] "; if (flags & ESM::LeveledListBase::AllLevels) properties += "AllLevels "; - // BUG? This flag apparently not present on creature lists... + // This flag apparently not present on creature lists... if (flags & ESM::LeveledListBase::Each) properties += "Each "; - // BUG! The unsused bits should be defined in LeveledListBase. int unused = (0xFFFFFFFF ^ (ESM::LeveledListBase::AllLevels| ESM::LeveledListBase::Each)); From 17dc67be0a0f5a651b9693f053aba49305c044d5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 11 Oct 2012 09:08:51 +0200 Subject: [PATCH 033/255] updated credits.txt --- credits.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/credits.txt b/credits.txt index 2968e3487f..45611a2d6f 100644 --- a/credits.txt +++ b/credits.txt @@ -16,6 +16,7 @@ Alexander Olofsson (Ace) Artem Kotsynyak (greye) athile BrotherBrick +Cory F. Cohen (cfcohen) Cris Mihalache (Mirceam) Douglas Diniz (Dgdiniz) Eli2 From f154031e54d21271d8ee0f01818613d13eb94355 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 11 Oct 2012 18:26:29 +0200 Subject: [PATCH 034/255] last bits of the gui --- apps/openmw/mwgui/spellcreationdialog.cpp | 123 +++++++++++++++++++++- apps/openmw/mwgui/spellcreationdialog.hpp | 13 +++ apps/openmw/mwgui/widgets.cpp | 8 +- apps/openmw/mwgui/widgets.hpp | 6 +- files/materials/water.shader | 2 +- files/mygui/openmw_edit_effect.layout | 79 ++++++++------ 6 files changed, 190 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 4e1c334dbb..02ce763ea0 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -1,5 +1,7 @@ #include "spellcreationdialog.hpp" +#include <boost/lexical_cast.hpp> + #include <components/esm_store/store.hpp> #include "../mwbase/windowmanager.hpp" @@ -49,21 +51,25 @@ namespace MWGui getWidget(mEffectImage, "EffectImage"); getWidget(mEffectName, "EffectName"); getWidget(mAreaText, "AreaText"); + getWidget(mDurationBox, "DurationBox"); + getWidget(mAreaBox, "AreaBox"); + getWidget(mMagnitudeBox, "MagnitudeBox"); mRangeButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onRangeButtonClicked); mOkButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onOkButtonClicked); mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onCancelButtonClicked); mDeleteButton->eventMouseButtonClick += MyGUI::newDelegate(this, &EditEffectDialog::onDeleteButtonClicked); + + mMagnitudeMinSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMinChanged); + mMagnitudeMaxSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onMagnitudeMaxChanged); + mDurationSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onDurationChanged); + mAreaSlider->eventScrollChangePosition += MyGUI::newDelegate(this, &EditEffectDialog::onAreaChanged); } void EditEffectDialog::open() { WindowModal::open(); center(); - - mEffect.mRange = ESM::RT_Self; - - onRangeButtonClicked(mRangeButton); } void EditEffectDialog::newEffect (const ESM::MagicEffect *effect) @@ -72,6 +78,25 @@ namespace MWGui mEditing = false; mDeleteButton->setVisible (false); + + mEffect.mRange = ESM::RT_Self; + + onRangeButtonClicked(mRangeButton); + + mMagnitudeMinSlider->setScrollPosition (0); + mMagnitudeMaxSlider->setScrollPosition (0); + mAreaSlider->setScrollPosition (0); + mDurationSlider->setScrollPosition (0); + + mDurationValue->setCaption("1"); + mMagnitudeMinValue->setCaption("1"); + mMagnitudeMaxValue->setCaption("- 1"); + mAreaValue->setCaption("0"); + + mEffect.mMagnMin = 1; + mEffect.mMagnMax = 1; + mEffect.mDuration = 1; + mEffect.mArea = 0; } void EditEffectDialog::editEffect (ESM::ENAMstruct effect) @@ -84,6 +109,16 @@ namespace MWGui mEditing = true; mDeleteButton->setVisible (true); + + mMagnitudeMinSlider->setScrollPosition (effect.mMagnMin-1); + mMagnitudeMaxSlider->setScrollPosition (effect.mMagnMax-1); + mAreaSlider->setScrollPosition (effect.mArea); + mDurationSlider->setScrollPosition (effect.mDuration-1); + + onMagnitudeMinChanged (mMagnitudeMinSlider, effect.mMagnMin-1); + onMagnitudeMaxChanged (mMagnitudeMinSlider, effect.mMagnMax-1); + onAreaChanged (mAreaSlider, effect.mArea); + onDurationChanged (mDurationSlider, effect.mDuration-1); } void EditEffectDialog::setMagicEffect (const ESM::MagicEffect *effect) @@ -99,6 +134,39 @@ namespace MWGui mEffectName->setCaptionWithReplacing("#{"+ESM::MagicEffect::effectIdToString (effect->mIndex)+"}"); mEffect.mEffectID = effect->mIndex; + + mMagicEffect = effect; + + updateBoxes(); + } + + void EditEffectDialog::updateBoxes() + { + static int startY = mMagnitudeBox->getPosition().top; + int curY = startY; + + mMagnitudeBox->setVisible (false); + mDurationBox->setVisible (false); + mAreaBox->setVisible (false); + + if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) + { + mMagnitudeBox->setPosition(mMagnitudeBox->getPosition().left, curY); + mMagnitudeBox->setVisible (true); + curY += mMagnitudeBox->getSize().height; + } + if (!(mMagicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) + { + mDurationBox->setPosition(mDurationBox->getPosition().left, curY); + mDurationBox->setVisible (true); + curY += mDurationBox->getSize().height; + } + if (mEffect.mRange == ESM::RT_Target) + { + mAreaBox->setPosition(mAreaBox->getPosition().left, curY); + mAreaBox->setVisible (true); + curY += mAreaBox->getSize().height; + } } void EditEffectDialog::onRangeButtonClicked (MyGUI::Widget* sender) @@ -114,6 +182,16 @@ namespace MWGui mAreaSlider->setVisible (mEffect.mRange != ESM::RT_Self); mAreaText->setVisible (mEffect.mRange != ESM::RT_Self); + + // cycle through range types until we find something that's allowed + if (mEffect.mRange == ESM::RT_Target && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTarget)) + onRangeButtonClicked(sender); + if (mEffect.mRange == ESM::RT_Self && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastSelf)) + onRangeButtonClicked(sender); + if (mEffect.mRange == ESM::RT_Touch && !(mMagicEffect->mData.mFlags & ESM::MagicEffect::CastTouch)) + onRangeButtonClicked(sender); + + updateBoxes(); } void EditEffectDialog::onDeleteButtonClicked (MyGUI::Widget* sender) @@ -148,6 +226,42 @@ namespace MWGui mEffect.mAttribute = attribute; } + void EditEffectDialog::onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos) + { + mMagnitudeMinValue->setCaption(boost::lexical_cast<std::string>(pos+1)); + mEffect.mMagnMin = pos+1; + + // trigger the check again (see below) + onMagnitudeMaxChanged(mMagnitudeMaxSlider, mMagnitudeMaxSlider->getScrollPosition ()); + } + + void EditEffectDialog::onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos) + { + // make sure the max value is actually larger or equal than the min value + size_t magnMin = std::abs(mEffect.mMagnMin); // should never be < 0, this is just here to avoid the compiler warning + if (pos+1 < magnMin) + { + pos = mEffect.mMagnMin-1; + sender->setScrollPosition (pos); + } + + mEffect.mMagnMax = pos+1; + + mMagnitudeMaxValue->setCaption("- " + boost::lexical_cast<std::string>(pos+1)); + } + + void EditEffectDialog::onDurationChanged (MyGUI::ScrollBar* sender, size_t pos) + { + mDurationValue->setCaption(boost::lexical_cast<std::string>(pos+1)); + mEffect.mDuration = pos+1; + } + + void EditEffectDialog::onAreaChanged (MyGUI::ScrollBar* sender, size_t pos) + { + mAreaValue->setCaption(boost::lexical_cast<std::string>(pos)); + mEffect.mArea = pos; + } + // ------------------------------------------------------------------------------------------------ SpellCreationDialog::SpellCreationDialog(MWBase::WindowManager &parWindowManager) @@ -356,6 +470,7 @@ namespace MWGui params.mMagnMin = it->mMagnMin; params.mMagnMax = it->mMagnMax; params.mRange = it->mRange; + params.mArea = it->mArea; MyGUI::Button* button = mUsedEffectsView->createWidget<MyGUI::Button>("", MyGUI::IntCoord(0, size.height, 0, 24), MyGUI::Align::Default); button->setUserData(i); diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index c5fffeb636..255b04cf6e 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -38,6 +38,10 @@ namespace MWGui MyGUI::Button* mRangeButton; + MyGUI::Widget* mDurationBox; + MyGUI::Widget* mMagnitudeBox; + MyGUI::Widget* mAreaBox; + MyGUI::TextBox* mMagnitudeMinValue; MyGUI::TextBox* mMagnitudeMaxValue; MyGUI::TextBox* mDurationValue; @@ -61,10 +65,19 @@ namespace MWGui void onOkButtonClicked (MyGUI::Widget* sender); void onCancelButtonClicked (MyGUI::Widget* sender); + void onMagnitudeMinChanged (MyGUI::ScrollBar* sender, size_t pos); + void onMagnitudeMaxChanged (MyGUI::ScrollBar* sender, size_t pos); + void onDurationChanged (MyGUI::ScrollBar* sender, size_t pos); + void onAreaChanged (MyGUI::ScrollBar* sender, size_t pos); + void setMagicEffect(const ESM::MagicEffect* effect); + void updateBoxes(); + protected: ESM::ENAMstruct mEffect; + + const ESM::MagicEffect* mMagicEffect; }; diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index d6a839760d..ed09b98058 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -362,6 +362,7 @@ SpellEffectList MWEffectList::effectListFromESM(const ESM::EffectList* effects) params.mMagnMin = it->mMagnMin; params.mMagnMax = it->mMagnMax; params.mRange = it->mRange; + params.mArea = it->mArea; result.push_back(params); } return result; @@ -437,6 +438,11 @@ void MWSpellEffect::updateWidgets() spellLine += " " + mWindowManager->getGameSettingString("sfor", "") + " " + boost::lexical_cast<std::string>(mEffectParams.mDuration) + ((mEffectParams.mDuration == 1) ? sec : secs); } + if (mEffectParams.mArea > 0) + { + spellLine += " #{sin} " + boost::lexical_cast<std::string>(mEffectParams.mArea) + " #{sfootarea}"; + } + // potions have no target if (!mEffectParams.mNoTarget) { @@ -450,7 +456,7 @@ void MWSpellEffect::updateWidgets() } } - static_cast<MyGUI::TextBox*>(mTextWidget)->setCaption(spellLine); + static_cast<MyGUI::TextBox*>(mTextWidget)->setCaptionWithReplacing(spellLine); mRequestedWidth = mTextWidget->getTextSize().width + 24; std::string path = std::string("icons\\") + magicEffect->mIcon; diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index 0a15e8e1fb..a41e1f1238 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -32,6 +32,7 @@ namespace MWGui , mRange(-1) , mDuration(-1) , mSkill(-1) + , mArea(0) , mAttribute(-1) , mEffectID(-1) , mNoTarget(false) @@ -51,6 +52,9 @@ namespace MWGui // value of -1 here means the value is unavailable int mMagnMin, mMagnMax, mRange, mDuration; + // value of 0 -> no area effect + int mArea; + bool operator==(const SpellEffectParams& other) const { if (mEffectID != other.mEffectID) @@ -66,7 +70,7 @@ namespace MWGui || mEffectID == 21 // drain skill || mEffectID == 83 // fortify skill || mEffectID == 26); // damage skill - return ((other.mSkill == mSkill) || !involvesSkill) && ((other.mAttribute == mAttribute) && !involvesAttribute); + return ((other.mSkill == mSkill) || !involvesSkill) && ((other.mAttribute == mAttribute) && !involvesAttribute) && (other.mArea == mArea); } }; diff --git a/files/materials/water.shader b/files/materials/water.shader index 947dc72f5e..6bd277eab6 100644 --- a/files/materials/water.shader +++ b/files/materials/water.shader @@ -298,7 +298,7 @@ } else { - float fogValue = shSaturate((depthPassthrough - fogParams.y) * fogParams.w); + float fogValue = shSaturate((length(cameraPos.xyz-position.xyz) - fogParams.y) * fogParams.w); shOutputColour(0).xyz = shLerp (shOutputColour(0).xyz, gammaCorrectRead(fogColor), fogValue); } diff --git a/files/mygui/openmw_edit_effect.layout b/files/mygui/openmw_edit_effect.layout index 884723febd..45ecb63edf 100644 --- a/files/mygui/openmw_edit_effect.layout +++ b/files/mygui/openmw_edit_effect.layout @@ -21,49 +21,60 @@ </Widget> <!-- Magnitude --> - <Widget type="TextBox" skin="NormalText" position="8 80 400 24"> - <Property key="Caption" value="#{sMagnitude}"/> - <Property key="TextAlign" value="Left HCenter"/> + <Widget type="Widget" position="8 80 400 70" name="MagnitudeBox"> + <Widget type="TextBox" skin="NormalText" position="0 0 400 24"> + <Property key="Caption" value="#{sMagnitude}"/> + <Property key="TextAlign" value="Left HCenter"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="122 0 210 20" name="MagnitudeMinValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="MagnitudeMinSlider"> + <Property key="Range" value="100"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="122 32 210 20" name="MagnitudeMaxValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="122 52 210 13" name="MagnitudeMaxSlider"> + <Property key="Range" value="100"/> + </Widget> </Widget> - <Widget type="TextBox" skin="SandText" position="130 80 210 20" name="MagnitudeMinValue"> - <Property key="TextAlign" value="Center"/> - <Property key="Caption" value="0"/> - </Widget> - <Widget type="ScrollBar" skin="MW_HSlider" position="130 100 210 13" name="MagnitudeMinSlider"> - </Widget> - - <Widget type="TextBox" skin="SandText" position="130 112 210 20" name="MagnitudeMaxValue"> - <Property key="TextAlign" value="Center"/> - <Property key="Caption" value="0"/> - </Widget> - <Widget type="ScrollBar" skin="MW_HSlider" position="130 132 210 13" name="MagnitudeMaxSlider"> - </Widget> <!-- Duration --> - <Widget type="TextBox" skin="NormalText" position="8 173 400 24"> - <Property key="Caption" value="#{sDuration}"/> - <Property key="TextAlign" value="Left Top"/> - </Widget> + <Widget type="Widget" position="8 153 400 40" name="DurationBox"> + <Widget type="TextBox" skin="NormalText" position="0 20 400 24"> + <Property key="Caption" value="#{sDuration}"/> + <Property key="TextAlign" value="Left Top"/> + </Widget> - <Widget type="TextBox" skin="SandText" position="130 153 210 20" name="DurationValue"> - <Property key="TextAlign" value="Center"/> - <Property key="Caption" value="0"/> - </Widget> - <Widget type="ScrollBar" skin="MW_HSlider" position="130 173 210 13" name="DurationSlider"> + <Widget type="TextBox" skin="SandText" position="122 0 210 20" name="DurationValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="DurationSlider"> + <Property key="Range" value="1440"/> + </Widget> </Widget> <!-- Area --> - <Widget type="TextBox" skin="NormalText" position="8 217 400 24" name="AreaText"> - <Property key="Caption" value="#{sArea}"/> - <Property key="TextAlign" value="Left Top"/> - </Widget> + <Widget type="Widget" position="8 197 400 40" name="AreaBox"> + <Widget type="TextBox" skin="NormalText" position="0 20 400 24" name="AreaText"> + <Property key="Caption" value="#{sArea}"/> + <Property key="TextAlign" value="Left Top"/> + </Widget> - <Widget type="TextBox" skin="SandText" position="130 197 210 20" name="AreaValue"> - <Property key="TextAlign" value="Center"/> - <Property key="Caption" value="0"/> - </Widget> - <Widget type="ScrollBar" skin="MW_HSlider" position="130 217 210 13" name="AreaSlider"> + <Widget type="TextBox" skin="SandText" position="122 0 210 20" name="AreaValue"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="0"/> + </Widget> + <Widget type="ScrollBar" skin="MW_HSlider" position="122 20 210 13" name="AreaSlider"> + <Property key="Range" value="51"/> + </Widget> </Widget> <Widget type="HBox" position="8 266 336 24"> From 85aaacb41a89e37f874ecdbd8f22ad55128dcb0f Mon Sep 17 00:00:00 2001 From: pvdk <pvdkloet@gmail.com> Date: Fri, 12 Oct 2012 02:25:14 +0200 Subject: [PATCH 035/255] Some cleaning of the launcher source dir --- apps/launcher/CMakeLists.txt | 35 +++-- apps/launcher/datafilespage.cpp | 10 +- apps/launcher/datafilespage.hpp | 1 - apps/launcher/graphicspage.cpp | 3 +- apps/launcher/maindialog.cpp | 2 + apps/launcher/model/datafilesmodel.cpp | 3 +- apps/launcher/pluginsmodel.cpp | 149 ---------------------- apps/launcher/pluginsmodel.hpp | 21 --- apps/launcher/pluginsview.cpp | 41 ------ apps/launcher/pluginsview.hpp | 29 ----- apps/launcher/{ => utils}/combobox.hpp | 0 apps/launcher/{ => utils}/filedialog.cpp | 0 apps/launcher/{ => utils}/filedialog.hpp | 0 apps/launcher/{ => utils}/lineedit.cpp | 0 apps/launcher/{ => utils}/lineedit.hpp | 0 apps/launcher/{ => utils}/naturalsort.cpp | 0 apps/launcher/{ => utils}/naturalsort.hpp | 0 17 files changed, 28 insertions(+), 266 deletions(-) delete mode 100644 apps/launcher/pluginsmodel.cpp delete mode 100644 apps/launcher/pluginsmodel.hpp delete mode 100644 apps/launcher/pluginsview.cpp delete mode 100644 apps/launcher/pluginsview.hpp rename apps/launcher/{ => utils}/combobox.hpp (100%) rename apps/launcher/{ => utils}/filedialog.cpp (100%) rename apps/launcher/{ => utils}/filedialog.hpp (100%) rename apps/launcher/{ => utils}/lineedit.cpp (100%) rename apps/launcher/{ => utils}/lineedit.hpp (100%) rename apps/launcher/{ => utils}/naturalsort.cpp (100%) rename apps/launcher/{ => utils}/naturalsort.hpp (100%) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 53631ebdde..92903b48d7 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -1,54 +1,51 @@ set(LAUNCHER datafilespage.cpp - filedialog.cpp graphicspage.cpp - lineedit.cpp main.cpp maindialog.cpp - naturalsort.cpp playpage.cpp - pluginsmodel.cpp - pluginsview.cpp - - launcher.rc model/datafilesmodel.cpp model/modelitem.cpp model/esm/esmfile.cpp + + utils/filedialog.cpp + utils/naturalsort.cpp + utils/lineedit.cpp + + launcher.rc ) set(LAUNCHER_HEADER - combobox.hpp datafilespage.hpp - filedialog.hpp graphicspage.hpp - lineedit.hpp maindialog.hpp - naturalsort.hpp playpage.hpp - pluginsmodel.hpp - pluginsview.hpp model/datafilesmodel.hpp model/modelitem.hpp model/esm/esmfile.hpp + + utils/combobox.hpp + utils/lineedit.hpp + utils/filedialog.hpp + utils/naturalsort.hpp ) # Headers that must be pre-processed set(LAUNCHER_HEADER_MOC - combobox.hpp datafilespage.hpp - filedialog.hpp graphicspage.hpp - lineedit.hpp maindialog.hpp playpage.hpp - pluginsmodel.hpp - pluginsview.hpp model/datafilesmodel.hpp model/modelitem.hpp model/esm/esmfile.hpp + + utils/combobox.hpp + utils/lineedit.hpp + utils/filedialog.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) @@ -87,7 +84,7 @@ add_executable(omwlauncher target_link_libraries(omwlauncher ${Boost_LIBRARIES} ${OGRE_LIBRARIES} - ${OGRE_STATIC_PLUGINS} + ${OGRE_STATIC_PLUGINS} ${QT_LIBRARIES} components ) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index c0a447e263..7b6c949c46 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -6,11 +6,12 @@ #include "model/datafilesmodel.hpp" #include "model/esm/esmfile.hpp" -#include "combobox.hpp" +#include "utils/combobox.hpp" +#include "utils/filedialog.hpp" +#include "utils/lineedit.hpp" +#include "utils/naturalsort.hpp" + #include "datafilespage.hpp" -#include "filedialog.hpp" -#include "lineedit.hpp" -#include "naturalsort.hpp" #include <boost/version.hpp> /** @@ -110,6 +111,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) mPluginsTable->setAlternatingRowColors(true); mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); mPluginsTable->horizontalHeader()->setStretchLastSection(true); + mPluginsTable->horizontalHeader()->hide(); mPluginsTable->verticalHeader()->setDefaultSectionSize(height); mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 6489912543..64f255b575 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -6,7 +6,6 @@ #include <components/files/collections.hpp> -#include "combobox.hpp" class QTableView; class QSortFilterProxyModel; diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index c3c39cffce..7685cb3c20 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -9,8 +9,9 @@ #include <components/files/ogreplugin.hpp> #include <components/settings/settings.hpp> +#include "utils/naturalsort.hpp" + #include "graphicspage.hpp" -#include "naturalsort.hpp" QString getAspect(int x, int y) { diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f7dafd3af5..f215b91188 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,5 +1,7 @@ #include <QtGui> +#include "utils/combobox.hpp" + #include "maindialog.hpp" #include "playpage.hpp" #include "graphicspage.hpp" diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index f009c3df00..0aa29a337a 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -6,8 +6,9 @@ #include "esm/esmfile.hpp" +#include "../utils/naturalsort.hpp" + #include "datafilesmodel.hpp" -#include "../naturalsort.hpp" DataFilesModel::DataFilesModel(QObject *parent) : QAbstractTableModel(parent) diff --git a/apps/launcher/pluginsmodel.cpp b/apps/launcher/pluginsmodel.cpp deleted file mode 100644 index 86bd53027f..0000000000 --- a/apps/launcher/pluginsmodel.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include <QMimeData> -#include <QBitArray> - -#include <limits> - -#include "pluginsmodel.hpp" - -PluginsModel::PluginsModel(QObject *parent) : QStandardItemModel(parent) -{ - -} - -void decodeDataRecursive(QDataStream &stream, QStandardItem *item) -{ - int colCount, childCount; - stream >> *item; - stream >> colCount >> childCount; - item->setColumnCount(colCount); - - int childPos = childCount; - - while(childPos > 0) { - childPos--; - QStandardItem *child = new QStandardItem(); - decodeDataRecursive(stream, child); - item->setChild( childPos / colCount, childPos % colCount, child); - } -} - -bool PluginsModel::dropMimeData(const QMimeData *data, Qt::DropAction action, - int row, int column, const QModelIndex &parent) -{ - // Code largely based on QStandardItemModel::dropMimeData - - // check if the action is supported - if (!data || !(action == Qt::CopyAction || action == Qt::MoveAction)) - return false; - - // check if the format is supported - QString format = QLatin1String("application/x-qstandarditemmodeldatalist"); - if (!data->hasFormat(format)) - return QAbstractItemModel::dropMimeData(data, action, row, column, parent); - - if (row > rowCount(parent)) - row = rowCount(parent); - if (row == -1) - row = rowCount(parent); - if (column == -1) - column = 0; - - // decode and insert - QByteArray encoded = data->data(format); - QDataStream stream(&encoded, QIODevice::ReadOnly); - - - //code based on QAbstractItemModel::decodeData - // adapted to work with QStandardItem - int top = std::numeric_limits<int>::max(); - int left = std::numeric_limits<int>::max(); - int bottom = 0; - int right = 0; - QVector<int> rows, columns; - QVector<QStandardItem *> items; - - while (!stream.atEnd()) { - int r, c; - QStandardItem *item = new QStandardItem(); - stream >> r >> c; - decodeDataRecursive(stream, item); - - rows.append(r); - columns.append(c); - items.append(item); - top = qMin(r, top); - left = qMin(c, left); - bottom = qMax(r, bottom); - right = qMax(c, right); - } - - // insert the dragged items into the table, use a bit array to avoid overwriting items, - // since items from different tables can have the same row and column - int dragRowCount = 0; - int dragColumnCount = right - left + 1; - - // Compute the number of continuous rows upon insertion and modify the rows to match - QVector<int> rowsToInsert(bottom + 1); - for (int i = 0; i < rows.count(); ++i) - rowsToInsert[rows.at(i)] = 1; - for (int i = 0; i < rowsToInsert.count(); ++i) { - if (rowsToInsert[i] == 1){ - rowsToInsert[i] = dragRowCount; - ++dragRowCount; - } - } - for (int i = 0; i < rows.count(); ++i) - rows[i] = top + rowsToInsert[rows[i]]; - - QBitArray isWrittenTo(dragRowCount * dragColumnCount); - - // make space in the table for the dropped data - int colCount = columnCount(parent); - if (colCount < dragColumnCount + column) { - insertColumns(colCount, dragColumnCount + column - colCount, parent); - colCount = columnCount(parent); - } - insertRows(row, dragRowCount, parent); - - row = qMax(0, row); - column = qMax(0, column); - - QStandardItem *parentItem = itemFromIndex (parent); - if (!parentItem) - parentItem = invisibleRootItem(); - - QVector<QPersistentModelIndex> newIndexes(items.size()); - // set the data in the table - for (int j = 0; j < items.size(); ++j) { - int relativeRow = rows.at(j) - top; - int relativeColumn = columns.at(j) - left; - int destinationRow = relativeRow + row; - int destinationColumn = relativeColumn + column; - int flat = (relativeRow * dragColumnCount) + relativeColumn; - // if the item was already written to, or we just can't fit it in the table, create a new row - if (destinationColumn >= colCount || isWrittenTo.testBit(flat)) { - destinationColumn = qBound(column, destinationColumn, colCount - 1); - destinationRow = row + dragRowCount; - insertRows(row + dragRowCount, 1, parent); - flat = (dragRowCount * dragColumnCount) + relativeColumn; - isWrittenTo.resize(++dragRowCount * dragColumnCount); - } - if (!isWrittenTo.testBit(flat)) { - newIndexes[j] = index(destinationRow, destinationColumn, parentItem->index()); - isWrittenTo.setBit(flat); - } - } - - for(int k = 0; k < newIndexes.size(); k++) { - if (newIndexes.at(k).isValid()) { - parentItem->setChild(newIndexes.at(k).row(), newIndexes.at(k).column(), items.at(k)); - } else { - delete items.at(k); - } - } - - // The important part, tell the view what is dropped - emit indexesDropped(newIndexes); - - return true; -} diff --git a/apps/launcher/pluginsmodel.hpp b/apps/launcher/pluginsmodel.hpp deleted file mode 100644 index 41df499b53..0000000000 --- a/apps/launcher/pluginsmodel.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef PLUGINSMODEL_H -#define PLUGINSMODEL_H - -#include <QStandardItemModel> - -class PluginsModel : public QStandardItemModel -{ - Q_OBJECT - -public: - PluginsModel(QObject *parent = 0); - ~PluginsModel() {}; - - bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - -signals: - void indexesDropped(QVector<QPersistentModelIndex> indexes); - -}; - -#endif \ No newline at end of file diff --git a/apps/launcher/pluginsview.cpp b/apps/launcher/pluginsview.cpp deleted file mode 100644 index 26cf337fb7..0000000000 --- a/apps/launcher/pluginsview.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include <QSortFilterProxyModel> - -#include "pluginsview.hpp" - -PluginsView::PluginsView(QWidget *parent) : QTableView(parent) -{ - setSelectionBehavior(QAbstractItemView::SelectRows); - setSelectionMode(QAbstractItemView::ExtendedSelection); - setEditTriggers(QAbstractItemView::NoEditTriggers); - setAlternatingRowColors(true); - setDragEnabled(true); - setDragDropMode(QAbstractItemView::InternalMove); - setDropIndicatorShown(true); - setDragDropOverwriteMode(false); - setContextMenuPolicy(Qt::CustomContextMenu); - -} - -void PluginsView::startDrag(Qt::DropActions supportedActions) -{ - selectionModel()->select( selectionModel()->selection(), - QItemSelectionModel::Select | QItemSelectionModel::Rows ); - QAbstractItemView::startDrag( supportedActions ); -} - -void PluginsView::setModel(QSortFilterProxyModel *model) -{ - QTableView::setModel(model); - - qRegisterMetaType< QVector<QPersistentModelIndex> >(); - - connect(model->sourceModel(), SIGNAL(indexesDropped(QVector<QPersistentModelIndex>)), - this, SLOT(selectIndexes(QVector<QPersistentModelIndex>)), Qt::QueuedConnection); -} - -void PluginsView::selectIndexes( QVector<QPersistentModelIndex> aIndexes ) -{ - selectionModel()->clearSelection(); - foreach( QPersistentModelIndex pIndex, aIndexes ) - selectionModel()->select( pIndex, QItemSelectionModel::Select | QItemSelectionModel::Rows ); -} diff --git a/apps/launcher/pluginsview.hpp b/apps/launcher/pluginsview.hpp deleted file mode 100644 index 484351e33a..0000000000 --- a/apps/launcher/pluginsview.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef PLUGINSVIEW_H -#define PLUGINSVIEW_H - -#include <QTableView> - -#include "pluginsmodel.hpp" - -class QSortFilterProxyModel; - -class PluginsView : public QTableView -{ - Q_OBJECT -public: - PluginsView(QWidget *parent = 0); - - PluginsModel* model() const - { return qobject_cast<PluginsModel*>(QAbstractItemView::model()); } - - void startDrag(Qt::DropActions supportedActions); - void setModel(QSortFilterProxyModel *model); - -public slots: - void selectIndexes(QVector<QPersistentModelIndex> aIndexes); - -}; - -Q_DECLARE_METATYPE(QVector<QPersistentModelIndex>) - -#endif diff --git a/apps/launcher/combobox.hpp b/apps/launcher/utils/combobox.hpp similarity index 100% rename from apps/launcher/combobox.hpp rename to apps/launcher/utils/combobox.hpp diff --git a/apps/launcher/filedialog.cpp b/apps/launcher/utils/filedialog.cpp similarity index 100% rename from apps/launcher/filedialog.cpp rename to apps/launcher/utils/filedialog.cpp diff --git a/apps/launcher/filedialog.hpp b/apps/launcher/utils/filedialog.hpp similarity index 100% rename from apps/launcher/filedialog.hpp rename to apps/launcher/utils/filedialog.hpp diff --git a/apps/launcher/lineedit.cpp b/apps/launcher/utils/lineedit.cpp similarity index 100% rename from apps/launcher/lineedit.cpp rename to apps/launcher/utils/lineedit.cpp diff --git a/apps/launcher/lineedit.hpp b/apps/launcher/utils/lineedit.hpp similarity index 100% rename from apps/launcher/lineedit.hpp rename to apps/launcher/utils/lineedit.hpp diff --git a/apps/launcher/naturalsort.cpp b/apps/launcher/utils/naturalsort.cpp similarity index 100% rename from apps/launcher/naturalsort.cpp rename to apps/launcher/utils/naturalsort.cpp diff --git a/apps/launcher/naturalsort.hpp b/apps/launcher/utils/naturalsort.hpp similarity index 100% rename from apps/launcher/naturalsort.hpp rename to apps/launcher/utils/naturalsort.hpp From 8ccb0907e647dc02f770aaf5357927605dac811f Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 12 Oct 2012 14:26:10 +0200 Subject: [PATCH 036/255] assertion -> exception; added the old effect flags again --- components/esm/loadmgef.cpp | 5 ++++- components/esm/loadmgef.hpp | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index 9542140367..d0230e3b6a 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -1,5 +1,7 @@ #include "loadmgef.hpp" +#include <boost/lexical_cast.hpp> + #include "esmreader.hpp" #include "esmwriter.hpp" @@ -231,7 +233,8 @@ std::string MagicEffect::effectIdToString(short effectID) // tribunal names[137] ="sEffectSummonFabricant"; - assert(names.find(effectID) != names.end() && "Unimplemented effect type"); + if (names.find(effectID) == names.end()) + throw std::runtime_error( std::string("Unimplemented effect ID ") + boost::lexical_cast<std::string>(effectID)); return names[effectID]; } diff --git a/components/esm/loadmgef.hpp b/components/esm/loadmgef.hpp index abf4ab5451..00349a3557 100644 --- a/components/esm/loadmgef.hpp +++ b/components/esm/loadmgef.hpp @@ -17,7 +17,7 @@ struct MagicEffect TargetAttribute = 0x2, // Affects a specific attribute, which is specified elsewhere in the effect structure. NoDuration = 0x4, // Has no duration. Only runs effect once on cast. NoMagnitude = 0x8, // Has no magnitude. - Negative = 0x10, // Counts as a negative effect. Interpreted as useful for attack, and is treated as a bad effect in alchemy. + Harmful = 0x10, // Counts as a negative effect. Interpreted as useful for attack, and is treated as a bad effect in alchemy. ContinuousVfx = 0x20, // The effect's hit particle VFX repeats for the full duration of the spell, rather than occuring once on hit. CastSelf = 0x40, // Allows range - cast on self. CastTouch = 0x80, // Allows range - cast on touch. @@ -25,7 +25,12 @@ struct MagicEffect UncappedDamage = 0x1000, // Negates multiple cap behaviours. Allows an effect to reduce an attribute below zero; removes the normal minimum effect duration of 1 second. NonRecastable = 0x4000, // Does not land if parent spell is already affecting target. Shows "you cannot re-cast" message for self target. Unreflectable = 0x10000, // Cannot be reflected, the effect always lands normally. - CasterLinked = 0x20000 // Must quench if caster is dead, or not an NPC/creature. Not allowed in containter/door trap spells. + CasterLinked = 0x20000, // Must quench if caster is dead, or not an NPC/creature. Not allowed in containter/door trap spells. + + SpellMaking = 0x0200, + Enchanting = 0x0400, + Negative = 0x0800 // A harmful effect. Will determine whether + // eg. NPCs regard this spell as an attack. (same as 0x10?) }; struct MEDTstruct From c991f68a2dbf929a7a158593042e4dd08163fc18 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Mon, 15 Oct 2012 21:54:19 +0200 Subject: [PATCH 037/255] buying created spell --- apps/openmw/mwbase/world.hpp | 6 ++++ apps/openmw/mwgui/spellcreationdialog.cpp | 42 +++++++++++++++++++++++ apps/openmw/mwworld/worldimp.cpp | 14 ++++++++ apps/openmw/mwworld/worldimp.hpp | 4 +++ 4 files changed, 66 insertions(+) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 521bbb988e..1cb120b5c3 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -28,6 +28,7 @@ namespace ESM struct Cell; struct Class; struct Potion; + struct Spell; } namespace ESMS @@ -235,6 +236,11 @@ namespace MWBase ///< Create a new recrod (of type potion) in the ESM store. /// \return ID, pointer to created record + virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record) + = 0; + ///< Create a new recrod (of type spell) in the ESM store. + /// \return ID, pointer to created record + virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record) = 0; ///< Create a new recrod (of type class) in the ESM store. diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 02ce763ea0..bb066e8ffe 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -8,6 +8,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" +#include "../mwbase/soundmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" @@ -297,7 +298,35 @@ namespace MWGui void SpellCreationDialog::onBuyButtonClicked (MyGUI::Widget* sender) { + if (mEffects.size() <= 0) + { + mWindowManager.messageBox ("#{sNotifyMessage30}", std::vector<std::string>()); + return; + } + if (mNameEdit->getCaption () == "") + { + mWindowManager.messageBox ("#{sNotifyMessage10}", std::vector<std::string>()); + return; + } + + ESM::Spell newSpell; + ESM::EffectList effectList; + effectList.mList = mEffects; + newSpell.mEffects = effectList; + newSpell.mName = mNameEdit->getCaption(); + newSpell.mData.mType = ESM::Spell::ST_Spell; + + std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(newSpell); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); + MWMechanics::Spells& spells = stats.getSpells(); + spells.add (result.first); + + MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); + + mWindowManager.removeGuiMode (GM_SpellCreation); } void SpellCreationDialog::open() @@ -372,6 +401,9 @@ namespace MWGui ToolTips::createMagicEffectToolTip (w, *it); } + + mEffects.clear(); + updateEffectsView (); } void EffectEditorBase::setWidgets (Widgets::MWList *availableEffectsList, MyGUI::ScrollView *usedEffectsView) @@ -413,6 +445,16 @@ namespace MWGui { short effectId = *sender->getUserData<short>(); + + for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) + { + if (it->mEffectID == effectId) + { + MWBase::Environment::get().getWindowManager()->messageBox ("#{sOnetypeEffectMessage}", std::vector<std::string>()); + return; + } + } + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); mAddEffectDialog.newEffect (effect); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 6fc228f0b5..495deb1ad8 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -802,6 +802,20 @@ namespace MWWorld return std::make_pair (stream.str(), created); } + std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record) + { + /// \todo See function above. + std::ostringstream stream; + stream << "$dynamic" << mNextDynamicRecord++; + + const ESM::Spell *created = + &mStore.spells.list.insert (std::make_pair (stream.str(), record)).first->second; + + mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL)); + + return std::make_pair (stream.str(), created); + } + const ESM::Cell *World::createRecord (const ESM::Cell& record) { if (record.mData.mFlags & ESM::Cell::Interior) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 90cd2151b6..830a299187 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -253,6 +253,10 @@ namespace MWWorld ///< Create a new recrod (of type potion) in the ESM store. /// \return ID, pointer to created record + virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record); + ///< Create a new recrod (of type spell) in the ESM store. + /// \return ID, pointer to created record + virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record); ///< Create a new recrod (of type class) in the ESM store. /// \return ID, pointer to created record From c9afe222bec803da4035e9e106b73acc55c5af77 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Tue, 16 Oct 2012 19:34:29 +0200 Subject: [PATCH 038/255] traveling now takes time --- apps/openmw/mwgui/travelwindow.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c2eb33c6cd..7dbfdf3154 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -4,10 +4,13 @@ #include <boost/lexical_cast.hpp> +#include <libs/openengine/ogre/fader.hpp> + #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/manualref.hpp" @@ -76,7 +79,6 @@ namespace MWGui toAdd->setCaptionWithReplacing(travelId+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); toAdd->setSize(toAdd->getTextSize().width,sLineHeight); toAdd->eventMouseWheel += MyGUI::newDelegate(this, &TravelWindow::onMouseWheel); - //toAdd->setUserString("ToolTipType", "Spell"); toAdd->setUserString("Destination", travelId); toAdd->setUserData(pos); toAdd->eventMouseButtonClick += MyGUI::newDelegate(this, &TravelWindow::onTravelButtonClick); @@ -141,6 +143,7 @@ namespace MWGui if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) { + //MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); ESM::Position pos = *_sender->getUserData<ESM::Position>(); std::string cellname = _sender->getUserString("Destination"); @@ -149,10 +152,23 @@ namespace MWGui MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y); MWWorld::CellStore* cell; if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname); - else cell = MWBase::Environment::get().getWorld()->getExterior(x,y); + else + { + cell = MWBase::Environment::get().getWorld()->getExterior(x,y); + ESM::Position PlayerPos = player.getRefData().getPosition(); + float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); + int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat()); + std::cout << time; + for(int i = 0;i < time;i++) + { + MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); + } + MWBase::Environment::get().getWorld()->advanceTime(time); + } MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]); mWindowManager.removeGuiMode(GM_Travel); mWindowManager.removeGuiMode(GM_Dialogue); + //MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(0.5); } } From 9583a1b8e94df2721a3b5256215ab0ba9ca18da5 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Tue, 16 Oct 2012 19:59:53 +0200 Subject: [PATCH 039/255] FadeOut/In, that's for you scrawl! --- apps/openmw/mwgui/travelwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 7dbfdf3154..fcdd800813 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -143,7 +143,7 @@ namespace MWGui if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) { - //MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1); + MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); ESM::Position pos = *_sender->getUserData<ESM::Position>(); std::string cellname = _sender->getUserString("Destination"); @@ -168,7 +168,7 @@ namespace MWGui MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]); mWindowManager.removeGuiMode(GM_Travel); mWindowManager.removeGuiMode(GM_Dialogue); - //MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(0.5); + MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(1); } } From 7d1e659960c2eaffeb9b61adf479bfa390cfd87b Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 16 Oct 2012 20:25:50 +0200 Subject: [PATCH 040/255] fading, greying out destinations you cant afford, warning fix --- apps/openmw/mwgui/loadingscreen.cpp | 5 +++ apps/openmw/mwgui/travelwindow.cpp | 70 +++++++++++++++-------------- extern/shiny | 2 +- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 170fc3bc5f..9ffb392218 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -6,10 +6,12 @@ #include <OgreCompositorChain.h> #include <OgreMaterial.h> +#include <openengine/ogre/fader.hpp> #include "../mwbase/environment.hpp" #include "../mwbase/inputmanager.hpp" +#include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" @@ -106,6 +108,7 @@ namespace MWGui if (mTimer.getMilliseconds () > mLastRenderTime + (1.f/loadingScreenFps) * 1000.f) { + float dt = mTimer.getMilliseconds () - mLastRenderTime; mLastRenderTime = mTimer.getMilliseconds (); if (mFirstLoad && mTimer.getMilliseconds () > mLastWallpaperChangeTime + 3000*1) @@ -151,6 +154,8 @@ namespace MWGui } } + MWBase::Environment::get().getWorld ()->getFader ()->update (dt); + mWindow->update(); if (!hasCompositor) diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index fcdd800813..da138a42ea 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -52,26 +52,28 @@ namespace MWGui void TravelWindow::addDestination(const std::string& travelId,ESM::Position pos,bool interior) { - //std::cout << "travel to" << travelId; - /*const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - int price = spell->data.cost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat();*/ int price = 0; - MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); - mCurrentY += sLineHeight; - /// \todo price adjustment depending on merchantile skill + if(interior) { - toAdd->setUserString("interior","y"); price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat(); } else { - toAdd->setUserString("interior","n"); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); } + + MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SpellText", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); + mCurrentY += sLineHeight; + /// \todo price adjustment depending on merchantile skill + if(interior) + toAdd->setUserString("interior","y"); + else + toAdd->setUserString("interior","n"); + std::ostringstream oss; oss << price; toAdd->setUserString("price",oss.str()); @@ -118,7 +120,7 @@ namespace MWGui addDestination (*iter); }*/ - for(int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) + for(unsigned int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) { std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName; bool interior = true; @@ -141,35 +143,35 @@ namespace MWGui int price; iss >> price; - if (mWindowManager.getInventoryWindow()->getPlayerGold()>=price) + assert (mWindowManager.getInventoryWindow()->getPlayerGold()>=price); + + MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + ESM::Position pos = *_sender->getUserData<ESM::Position>(); + std::string cellname = _sender->getUserString("Destination"); + int x,y; + bool interior = _sender->getUserString("interior") == "y"; + MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y); + MWWorld::CellStore* cell; + if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname); + else { - MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(1); - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - ESM::Position pos = *_sender->getUserData<ESM::Position>(); - std::string cellname = _sender->getUserString("Destination"); - int x,y; - bool interior = _sender->getUserString("interior") == "y"; - MWBase::Environment::get().getWorld()->positionToIndex(pos.pos[0],pos.pos[1],x,y); - MWWorld::CellStore* cell; - if(interior) cell = MWBase::Environment::get().getWorld()->getInterior(cellname); - else + cell = MWBase::Environment::get().getWorld()->getExterior(x,y); + ESM::Position PlayerPos = player.getRefData().getPosition(); + float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); + int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat()); + std::cout << time; + for(int i = 0;i < time;i++) { - cell = MWBase::Environment::get().getWorld()->getExterior(x,y); - ESM::Position PlayerPos = player.getRefData().getPosition(); - float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); - int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat()); - std::cout << time; - for(int i = 0;i < time;i++) - { - MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); - } - MWBase::Environment::get().getWorld()->advanceTime(time); + MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); } - MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]); - mWindowManager.removeGuiMode(GM_Travel); - mWindowManager.removeGuiMode(GM_Dialogue); - MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(1); + MWBase::Environment::get().getWorld()->advanceTime(time); } + MWBase::Environment::get().getWorld()->moveObject(player,*cell,pos.pos[0],pos.pos[1],pos.pos[2]); + mWindowManager.removeGuiMode(GM_Travel); + mWindowManager.removeGuiMode(GM_Dialogue); + MWBase::Environment::get().getWorld ()->getFader ()->fadeOut(0); + MWBase::Environment::get().getWorld ()->getFader ()->fadeIn(1); } void TravelWindow::onCancelButtonClicked(MyGUI::Widget* _sender) diff --git a/extern/shiny b/extern/shiny index 4750676ac4..f17c4ebab0 160000 --- a/extern/shiny +++ b/extern/shiny @@ -1 +1 @@ -Subproject commit 4750676ac46a7aaa86bca53dc68c5a1ba11f3bc1 +Subproject commit f17c4ebab0e7a1f3bbb25fd9b3dbef2bd742536a From 5e9153e2b8766ff42b9aadcba6aaba2e5bb50688 Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski <lgromanowski@gmail.com> Date: Tue, 16 Oct 2012 23:16:14 +0300 Subject: [PATCH 041/255] Issue #423: Wrong usage of "Version" Remove "Version" line from openmw.desktop file (according to http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s05.html it's not required). Fixes #423 Signed-off-by: Lukasz Gromanowski <lgromanowski@gmail.com> --- files/openmw.desktop | 1 - 1 file changed, 1 deletion(-) diff --git a/files/openmw.desktop b/files/openmw.desktop index 234f660c62..118cd3bbe6 100644 --- a/files/openmw.desktop +++ b/files/openmw.desktop @@ -1,5 +1,4 @@ [Desktop Entry] -Version=${OPENMW_VERSION} Type=Application Name=OpenMW Launcher GenericName=Role Playing Game From 6acbea822b70b8b7e5f5c6f6222ac892da4a5e26 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 16 Oct 2012 23:59:03 +0200 Subject: [PATCH 042/255] splash screen directory listing --- apps/openmw/mwgui/loadingscreen.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 170fc3bc5f..bb3aade617 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -6,6 +6,8 @@ #include <OgreCompositorChain.h> #include <OgreMaterial.h> +#include <boost/algorithm/string.hpp> + #include "../mwbase/environment.hpp" @@ -207,20 +209,16 @@ namespace MWGui void LoadingScreen::changeWallpaper () { - /// \todo use a directory listing here std::vector<std::string> splash; - splash.push_back ("Splash_Bonelord.tga"); - splash.push_back ("Splash_ClannDaddy.tga"); - splash.push_back ("Splash_Clannfear.tga"); - splash.push_back ("Splash_Daedroth.tga"); - splash.push_back ("Splash_Hunger.tga"); - splash.push_back ("Splash_KwamaWarrior.tga"); - splash.push_back ("Splash_Netch.tga"); - splash.push_back ("Splash_NixHound.tga"); - splash.push_back ("Splash_Siltstriker.tga"); - splash.push_back ("Splash_Skeleton.tga"); - splash.push_back ("Splash_SphereCenturion.tga"); + Ogre::StringVectorPtr resources = Ogre::ResourceGroupManager::getSingleton ().listResourceNames ("General", false); + for (Ogre::StringVector::const_iterator it = resources->begin(); it != resources->end(); ++it) + { + std::string start = it->substr(0, 6); + boost::to_lower(start); + if (start == "splash") + splash.push_back (*it); + } mBackgroundImage->setImageTexture (splash[rand() % splash.size()]); } } From 84a4fd56c32de6aa954c6e92490191926c4106a7 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 17 Oct 2012 12:39:45 +0200 Subject: [PATCH 043/255] consider all files in Splash directory --- apps/openmw/engine.cpp | 5 ++--- apps/openmw/mwgui/loadingscreen.cpp | 6 +++++- components/bsa/bsa_archive.cpp | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index adbfca129d..9b1a550254 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -163,9 +163,8 @@ void OMW::Engine::loadBSA() std::cout << "Data dir " << dataDirectory << std::endl; Bsa::addDir(dataDirectory, mFSStrict); - // Workaround: Mygui does not find textures in non-BSA subfolders, _unless_ they are explicitely added like this - // For splash screens, this is OK to do, but eventually we will need an investigation why this is necessary - Bsa::addDir(dataDirectory + "/Splash", mFSStrict); + // Workaround until resource listing capabilities are added to DirArchive, we need those to list available splash screens + addResourcesDirectory (dataDirectory); } } diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index bb3aade617..cfe54c91ae 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -216,9 +216,13 @@ namespace MWGui { std::string start = it->substr(0, 6); boost::to_lower(start); + if (start == "splash") splash.push_back (*it); } - mBackgroundImage->setImageTexture (splash[rand() % splash.size()]); + std::string randomSplash = splash[rand() % splash.size()]; + + Ogre::TexturePtr tex = Ogre::TextureManager::getSingleton ().load (randomSplash, "General"); + mBackgroundImage->setImageTexture (randomSplash); } } diff --git a/components/bsa/bsa_archive.cpp b/components/bsa/bsa_archive.cpp index 081207b0c8..8380b08388 100644 --- a/components/bsa/bsa_archive.cpp +++ b/components/bsa/bsa_archive.cpp @@ -375,7 +375,7 @@ void addBSA(const std::string& name, const std::string& group) { insertBSAFactory(); ResourceGroupManager::getSingleton(). - addResourceLocation(name, "BSA", group); + addResourceLocation(name, "BSA", group, true); } void addDir(const std::string& name, const bool& fs, const std::string& group) @@ -384,7 +384,7 @@ void addDir(const std::string& name, const bool& fs, const std::string& group) insertDirFactory(); ResourceGroupManager::getSingleton(). - addResourceLocation(name, "Dir", group); + addResourceLocation(name, "Dir", group, true); } } From 6be092e26819baa5142b1a059079e105b4921690 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 17 Oct 2012 12:41:24 +0200 Subject: [PATCH 044/255] substr check --- apps/openmw/mwgui/loadingscreen.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index cfe54c91ae..2eccc8f2af 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -214,6 +214,8 @@ namespace MWGui Ogre::StringVectorPtr resources = Ogre::ResourceGroupManager::getSingleton ().listResourceNames ("General", false); for (Ogre::StringVector::const_iterator it = resources->begin(); it != resources->end(); ++it) { + if (it->size() < 6) + continue; std::string start = it->substr(0, 6); boost::to_lower(start); From 1a2034b4dddfacafd52a2fbd2eeec72e008d4b57 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 17 Oct 2012 18:03:02 +0200 Subject: [PATCH 045/255] training window --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwbase/windowmanager.hpp | 1 + apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 3 + apps/openmw/mwgui/dialogue.cpp | 8 + apps/openmw/mwgui/dialogue.hpp | 3 +- apps/openmw/mwgui/mode.hpp | 1 + apps/openmw/mwgui/trainingwindow.cpp | 152 ++++++++++++++++++ apps/openmw/mwgui/trainingwindow.hpp | 36 +++++ apps/openmw/mwgui/windowmanagerimp.cpp | 16 ++ apps/openmw/mwgui/windowmanagerimp.hpp | 3 + apps/openmw/mwsound/ffmpeg_decoder.hpp | 2 +- components/esm/aipackage.hpp | 2 - files/mygui/CMakeLists.txt | 1 + files/mygui/openmw_trainingwindow.layout | 31 ++++ 14 files changed, 256 insertions(+), 5 deletions(-) create mode 100644 apps/openmw/mwgui/trainingwindow.cpp create mode 100644 apps/openmw/mwgui/trainingwindow.hpp create mode 100644 files/mygui/openmw_trainingwindow.layout diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index bc4e10501e..d3698b53e2 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -30,7 +30,7 @@ add_openmw_dir (mwgui formatting inventorywindow container hud countdialog tradewindow settingswindow confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog - enchantingdialog + enchantingdialog trainingwindow ) add_openmw_dir (mwdialogue diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index 462aef014c..f4c78f5fb1 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -230,6 +230,7 @@ namespace MWBase virtual void startSpellMaking(MWWorld::Ptr actor) = 0; virtual void startEnchanting(MWWorld::Ptr actor) = 0; + virtual void startTraining(MWWorld::Ptr actor) = 0; }; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 3a51ed2b64..063794ebaa 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -801,6 +801,9 @@ namespace MWDialogue if (services & ESM::NPC::Spellmaking) windowServices |= MWGui::DialogueWindow::Service_CreateSpells; + if (services & ESM::NPC::Training) + windowServices |= MWGui::DialogueWindow::Service_Training; + if (services & ESM::NPC::Enchanting) windowServices |= MWGui::DialogueWindow::Service_Enchant; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index d03724628f..d5b4ca672f 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -147,6 +147,11 @@ void DialogueWindow::onSelectTopic(std::string topic) mWindowManager.pushGuiMode(GM_Enchanting); mWindowManager.startEnchanting (mPtr); } + else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()) + { + mWindowManager.pushGuiMode(GM_Training); + mWindowManager.startTraining (mPtr); + } else MWBase::Environment::get().getDialogueManager()->keywordSelected(lower_string(topic)); } @@ -181,6 +186,9 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords) if (mServices & Service_Enchant) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); + if (mServices & Service_Training) + mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()); + if (anyService) mTopicsList->addSeparator(); diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index acbe75eed3..1592e49ee1 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -57,7 +57,8 @@ namespace MWGui Service_Trade = 0x01, Service_BuySpells = 0x02, Service_CreateSpells = 0x04, - Service_Enchant = 0x08 + Service_Enchant = 0x08, + Service_Training = 0x10 }; protected: diff --git a/apps/openmw/mwgui/mode.hpp b/apps/openmw/mwgui/mode.hpp index 7fd033f5ee..e594a5d0b0 100644 --- a/apps/openmw/mwgui/mode.hpp +++ b/apps/openmw/mwgui/mode.hpp @@ -24,6 +24,7 @@ namespace MWGui GM_SpellBuying, GM_SpellCreation, GM_Enchanting, + GM_Training, GM_Levelup, diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp new file mode 100644 index 0000000000..536b3a3a6d --- /dev/null +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -0,0 +1,152 @@ +#include "trainingwindow.hpp" + +#include <boost/lexical_cast.hpp> + +#include <openengine/ogre/fader.hpp> + +#include "../mwbase/windowmanager.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + +#include "../mwworld/player.hpp" + +#include "../mwmechanics/npcstats.hpp" + +#include "inventorywindow.hpp" +#include "tradewindow.hpp" +#include "tooltips.hpp" + +namespace MWGui +{ + + TrainingWindow::TrainingWindow(MWBase::WindowManager &parWindowManager) + : WindowBase("openmw_trainingwindow.layout", parWindowManager) + , mFadeTimeRemaining(0) + { + getWidget(mTrainingOptions, "TrainingOptions"); + getWidget(mCancelButton, "CancelButton"); + getWidget(mPlayerGold, "PlayerGold"); + + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onCancelButtonClicked); + } + + void TrainingWindow::open() + { + center(); + } + + void TrainingWindow::startTraining (MWWorld::Ptr actor) + { + mPtr = actor; + + mPlayerGold->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold())); + + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(actor).getNpcStats (actor); + + // NPC can train you in his best 3 skills + std::vector< std::pair<int, int> > bestSkills; + bestSkills.push_back (std::make_pair(-1, -1)); + bestSkills.push_back (std::make_pair(-1, -1)); + bestSkills.push_back (std::make_pair(-1, -1)); + + for (int i=0; i<ESM::Skill::Length; ++i) + { + int value = npcStats.getSkill (i).getBase (); + + for (int j=0; j<3; ++j) + { + if (value > bestSkills[j].second) + { + if (j<2) + { + bestSkills[j+1] = bestSkills[j]; + } + bestSkills[j] = std::make_pair(i, value); + break; + } + } + } + + MyGUI::EnumeratorWidgetPtr widgets = mTrainingOptions->getEnumerator (); + MyGUI::Gui::getInstance ().destroyWidgets (widgets); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); + MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); + + for (int i=0; i<3; ++i) + { + /// \todo mercantile skill + int price = pcStats.getSkill (bestSkills[i].first).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); + + std::string skin = (price > mWindowManager.getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton"; + + MyGUI::Button* button = mTrainingOptions->createWidget<MyGUI::Button>(skin, + MyGUI::IntCoord(5, 5+i*18, mTrainingOptions->getWidth()-10, 18), MyGUI::Align::Default); + + button->setUserData(bestSkills[i].first); + button->eventMouseButtonClick += MyGUI::newDelegate(this, &TrainingWindow::onTrainingSelected); + + button->setCaptionWithReplacing("#{" + ESM::Skill::sSkillNameIds[bestSkills[i].first] + "} - " + boost::lexical_cast<std::string>(price)); + + button->setSize(button->getTextSize ().width+12, button->getSize().height); + + ToolTips::createSkillToolTip (button, bestSkills[i].first); + } + + center(); + } + + void TrainingWindow::onReferenceUnavailable () + { + mWindowManager.removeGuiMode(GM_Training); + } + + void TrainingWindow::onCancelButtonClicked (MyGUI::Widget *sender) + { + mWindowManager.removeGuiMode (GM_Training); + } + + void TrainingWindow::onTrainingSelected (MyGUI::Widget *sender) + { + int skillId = *sender->getUserData<int>(); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); + MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); + + /// \todo mercantile skill + int price = pcStats.getSkill (skillId).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); + + if (mWindowManager.getInventoryWindow()->getPlayerGold()<price) + return; + + // increase skill + MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); + const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( + playerRef->base->mClass); + pcStats.increaseSkill (skillId, *class_, true); + + // remove gold + mWindowManager.getTradeWindow()->addOrRemoveGold(-price); + + // go back to game mode + mWindowManager.removeGuiMode (GM_Training); + mWindowManager.removeGuiMode (GM_Dialogue); + + // advance time + MWBase::Environment::get().getWorld ()->advanceTime (2); + + MWBase::Environment::get().getWorld ()->getFader()->fadeOut(0.25); + mFadeTimeRemaining = 0.5; + } + + void TrainingWindow::onFrame(float dt) + { + if (mFadeTimeRemaining <= 0) + return; + + mFadeTimeRemaining -= dt; + + if (mFadeTimeRemaining <= 0) + MWBase::Environment::get().getWorld ()->getFader()->fadeIn(0.25); + } +} diff --git a/apps/openmw/mwgui/trainingwindow.hpp b/apps/openmw/mwgui/trainingwindow.hpp new file mode 100644 index 0000000000..f2ef1714ee --- /dev/null +++ b/apps/openmw/mwgui/trainingwindow.hpp @@ -0,0 +1,36 @@ +#ifndef MWGUI_TRAININGWINDOW_H +#define MWGUI_TRAININGWINDOW_H + +#include "window_base.hpp" +#include "referenceinterface.hpp" + +namespace MWGui +{ + + class TrainingWindow : public WindowBase, public ReferenceInterface + { + public: + TrainingWindow(MWBase::WindowManager& parWindowManager); + + virtual void open(); + + void startTraining(MWWorld::Ptr actor); + + void onFrame(float dt); + + protected: + virtual void onReferenceUnavailable (); + + void onCancelButtonClicked (MyGUI::Widget* sender); + void onTrainingSelected(MyGUI::Widget* sender); + + MyGUI::Widget* mTrainingOptions; + MyGUI::Button* mCancelButton; + MyGUI::TextBox* mPlayerGold; + + float mFadeTimeRemaining; + }; + +} + +#endif diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 906bb2ca7e..ea5c5b6cb2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -48,6 +48,7 @@ #include "waitdialog.hpp" #include "spellcreationdialog.hpp" #include "enchantingdialog.hpp" +#include "trainingwindow.hpp" using namespace MWGui; @@ -79,6 +80,7 @@ WindowManager::WindowManager( , mWaitDialog(NULL) , mSpellCreationDialog(NULL) , mEnchantingDialog(NULL) + , mTrainingWindow(NULL) , mPlayerClass() , mPlayerName() , mPlayerRaceId() @@ -161,6 +163,7 @@ WindowManager::WindowManager( mWaitDialog = new WaitDialog(*this); mSpellCreationDialog = new SpellCreationDialog(*this); mEnchantingDialog = new EnchantingDialog(*this); + mTrainingWindow = new TrainingWindow(*this); mLoadingScreen = new LoadingScreen(mOgre->getScene (), mOgre->getWindow (), *this); mLoadingScreen->onResChange (w,h); @@ -218,6 +221,7 @@ WindowManager::~WindowManager() delete mWaitDialog; delete mSpellCreationDialog; delete mEnchantingDialog; + delete mTrainingWindow; cleanupGarbage(); @@ -269,6 +273,7 @@ void WindowManager::updateVisible() mWaitDialog->setVisible(false); mSpellCreationDialog->setVisible(false); mEnchantingDialog->setVisible(false); + mTrainingWindow->setVisible(false); mHud->setVisible(true); @@ -375,6 +380,9 @@ void WindowManager::updateVisible() case GM_Enchanting: mEnchantingDialog->setVisible(true); break; + case GM_Training: + mTrainingWindow->setVisible(true); + break; case GM_InterMessageBox: break; case GM_Journal: @@ -574,6 +582,9 @@ void WindowManager::onFrame (float frameDuration) mHud->onFrame(frameDuration); + mTrainingWindow->onFrame (frameDuration); + + mTrainingWindow->checkReferenceAvailable(); mDialogueWindow->checkReferenceAvailable(); mTradeWindow->checkReferenceAvailable(); mSpellBuyingWindow->checkReferenceAvailable(); @@ -993,3 +1004,8 @@ void WindowManager::startEnchanting (MWWorld::Ptr actor) { mEnchantingDialog->startEnchanting (actor); } + +void WindowManager::startTraining(MWWorld::Ptr actor) +{ + mTrainingWindow->startTraining(actor); +} diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index d3890f6351..8b0e744db9 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -66,6 +66,7 @@ namespace MWGui class WaitDialog; class SpellCreationDialog; class EnchantingDialog; + class TrainingWindow; class WindowManager : public MWBase::WindowManager { @@ -215,6 +216,7 @@ namespace MWGui virtual void startSpellMaking(MWWorld::Ptr actor); virtual void startEnchanting(MWWorld::Ptr actor); + virtual void startTraining(MWWorld::Ptr actor); private: OEngine::GUI::MyGUIManager *mGuiManager; @@ -245,6 +247,7 @@ namespace MWGui WaitDialog* mWaitDialog; SpellCreationDialog* mSpellCreationDialog; EnchantingDialog* mEnchantingDialog; + TrainingWindow* mTrainingWindow; CharacterCreation* mCharGen; diff --git a/apps/openmw/mwsound/ffmpeg_decoder.hpp b/apps/openmw/mwsound/ffmpeg_decoder.hpp index 4344397c70..7b028e1d0b 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.hpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.hpp @@ -54,6 +54,6 @@ namespace MWSound #ifndef DEFAULT_DECODER #define DEFAULT_DECODER (::MWSound::FFmpeg_Decoder) #endif -}; +} #endif diff --git a/components/esm/aipackage.hpp b/components/esm/aipackage.hpp index 8e55b68892..3128fe0c61 100644 --- a/components/esm/aipackage.hpp +++ b/components/esm/aipackage.hpp @@ -18,8 +18,6 @@ namespace ESM { // These are probabilities char mHello, mU1, mFight, mFlee, mAlarm, mU2, mU3, mU4; - // The last u's might be the skills that this NPC can train you - // in? int mServices; // See the Services enum }; // 12 bytes diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index a33d59ef6c..1354271d54 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -78,6 +78,7 @@ set(MYGUI_FILES openmw_spellcreation_dialog.layout openmw_edit_effect.layout openmw_enchanting_dialog.layout + openmw_trainingwindow.layout smallbars.png VeraMono.ttf markers.png diff --git a/files/mygui/openmw_trainingwindow.layout b/files/mygui/openmw_trainingwindow.layout new file mode 100644 index 0000000000..e9855a33b1 --- /dev/null +++ b/files/mygui/openmw_trainingwindow.layout @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<MyGUI type="Layout"> + <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 319 200" name="_Main"> + + <Widget type="TextBox" skin="NormalText" position="0 5 319 24" name="Select" align="Right Top"> + <Property key="TextAlign" value="Center"/> + <Property key="Caption" value="#{sServiceTrainingTitle}"/> + </Widget> + <Widget type="TextBox" skin="SandText" position="5 30 319 24" name="Travel" align="Right Top"> + <Property key="TextAlign" value="Left"/> + <Property key="Caption" value="#{sTrainingServiceTitle}"/> + </Widget> + + + <Widget type="Widget" skin="MW_Box" position="6 54 299 100" align="Left Top" name="TrainingOptions"> + </Widget> + + + <Widget type="TextBox" skin="SandText" position="8 255 200 24" name="PlayerGold" align="Right Top"> + <Property key="TextAlign" value="Left"/> + <Property key="Caption" value="Draken (754)"/> + </Widget> + <Widget type="AutoSizedButton" skin="MW_Button" position="244 163 60 24" name="CancelButton" align="Right Top"> + <Property key="ExpandDirection" value="Left"/> + <Property key="Caption" value="#{sCancel}"/> + </Widget> + + </Widget> + +</MyGUI> From 125315ebe7115bbe3aad2da6a215c7a1a6539f90 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 17 Oct 2012 18:21:24 +0200 Subject: [PATCH 046/255] remove a cout --- apps/openmw/mwgui/dialogue.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index f0d15aed5a..23d2197b70 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -140,10 +140,8 @@ void DialogueWindow::onSelectTopic(std::string topic) } else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()) { - std::cout << "travel!"; mWindowManager.pushGuiMode(GM_Travel); mWindowManager.getTravelWindow()->startTravel(mPtr); - //mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); } else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellMakingMenuTitle")->getString()) { From e80394c0b57652b95d6899de361a96ef2aaef646 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 17 Oct 2012 18:48:29 +0200 Subject: [PATCH 047/255] fix training limit --- apps/openmw/mwgui/trainingwindow.cpp | 7 +++++++ files/mygui/openmw_trainingwindow.layout | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 536b3a3a6d..af61b3487b 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -119,6 +119,13 @@ namespace MWGui if (mWindowManager.getInventoryWindow()->getPlayerGold()<price) return; + MWMechanics::NpcStats& npcStats = MWWorld::Class::get(mPtr).getNpcStats (mPtr); + if (npcStats.getSkill (skillId).getBase () <= pcStats.getSkill (skillId).getBase ()) + { + mWindowManager.messageBox ("#{sServiceTrainingWords}", std::vector<std::string>()); + return; + } + // increase skill MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( diff --git a/files/mygui/openmw_trainingwindow.layout b/files/mygui/openmw_trainingwindow.layout index e9855a33b1..aa39d0a5c4 100644 --- a/files/mygui/openmw_trainingwindow.layout +++ b/files/mygui/openmw_trainingwindow.layout @@ -21,7 +21,7 @@ <Property key="TextAlign" value="Left"/> <Property key="Caption" value="Draken (754)"/> </Widget> - <Widget type="AutoSizedButton" skin="MW_Button" position="244 163 60 24" name="CancelButton" align="Right Top"> + <Widget type="AutoSizedButton" skin="MW_Button" position="244 161 60 24" name="CancelButton" align="Right Top"> <Property key="ExpandDirection" value="Left"/> <Property key="Caption" value="#{sCancel}"/> </Widget> From 0a19b5603103bfb6a4f81a9112b4122a59e31fe8 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 17 Oct 2012 18:49:49 +0200 Subject: [PATCH 048/255] fix gold label --- files/mygui/openmw_trainingwindow.layout | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/files/mygui/openmw_trainingwindow.layout b/files/mygui/openmw_trainingwindow.layout index aa39d0a5c4..c58bd0ab3a 100644 --- a/files/mygui/openmw_trainingwindow.layout +++ b/files/mygui/openmw_trainingwindow.layout @@ -17,9 +17,8 @@ </Widget> - <Widget type="TextBox" skin="SandText" position="8 255 200 24" name="PlayerGold" align="Right Top"> + <Widget type="TextBox" skin="SandText" position="8 161 200 24" name="PlayerGold" align="Right Top"> <Property key="TextAlign" value="Left"/> - <Property key="Caption" value="Draken (754)"/> </Widget> <Widget type="AutoSizedButton" skin="MW_Button" position="244 161 60 24" name="CancelButton" align="Right Top"> <Property key="ExpandDirection" value="Left"/> From 5fbca239dd4da63fecd0634674d7e80e43e4e0b6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 18 Oct 2012 14:02:06 +0200 Subject: [PATCH 049/255] Issue #61: potion creation (1st part; still missing some implementations) --- apps/openmw/mwmechanics/alchemy.cpp | 308 +++++++++++++++++++++++++++- apps/openmw/mwmechanics/alchemy.hpp | 62 +++++- components/esm/loadmgef.hpp | 2 + 3 files changed, 369 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 6d3deed3c4..c8a3cf162f 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -1,15 +1,259 @@ #include "alchemy.hpp" +#include <cstdlib> + #include <algorithm> #include <stdexcept> +#include <components/esm/loadskil.hpp> +#include <components/esm/loadappa.hpp> +#include <components/esm/loadgmst.hpp> +#include <components/esm/loadmgef.hpp> + +#include <components/esm_store/store.hpp> + +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" + #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/cellstore.hpp" + +#include "magiceffects.hpp" +#include "creaturestats.hpp" +#include "npcstats.hpp" + +std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const +{ + std::set<EffectKey> effects; + + for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter) + { + if (!iter->isEmpty()) + { + const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>(); + + for (int i=0; i<4; ++i) + if (ingredient->base->mData.mEffectID[i]!=-1) + effects.insert (EffectKey ( + ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ? + ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i])); + } + } + + return effects; +} + +void MWMechanics::Alchemy::filterEffects (std::set<EffectKey>& effects) const +{ + std::set<EffectKey>::iterator iter = effects.begin(); + + while (iter!=effects.end()) + { + bool remove = false; + + const EffectKey& key = *iter; + + { // dodge pointless g++ warning + for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter) + { + bool found = false; + + const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>(); + + for (int i=0; i<4; ++i) + if (key.mId==ingredient->base->mData.mEffectID[i] && + (key.mArg==ingredient->base->mData.mSkills[i] || + key.mArg==ingredient->base->mData.mAttributes[i])) + { + found = true; + break; + } + + if (!found) + { + remove = true; + break; + } + } + } + + if (remove) + effects.erase (iter++); + else + ++iter; + } +} + +void MWMechanics::Alchemy::applyTools (int flags, float& value) const +{ + bool magnitude = !(flags & ESM::MagicEffect::NoMagnitude); + bool duration = !(flags & ESM::MagicEffect::NoDuration); + bool negative = flags & (ESM::MagicEffect::Negative | ESM::MagicEffect::Negative2); + + int tool = negative ? ESM::Apparatus::Retort : ESM::Apparatus::Albemic; + + int setup = 0; + + if (!mTools[tool].isEmpty() && !mTools[ESM::Apparatus::Calcinator].isEmpty()) + setup = 1; + else if (!mTools[tool].isEmpty()) + setup = 2; + else if (!mTools[ESM::Apparatus::Calcinator].isEmpty()) + setup = 3; + else + return; + + float toolQuality = setup==1 || setup==2 ? mTools[tool].get<ESM::Apparatus>()->base->mData.mQuality : 0; + float calcinatorQuality = setup==1 || setup==3 ? + mTools[ESM::Apparatus::Calcinator].get<ESM::Apparatus>()->base->mData.mQuality : 0; + + float quality = 1; + + switch (setup) + { + case 1: + + quality = negative ? 2 * toolQuality + 3 * calcinatorQuality : + (magnitude && duration ? + 2 * toolQuality + calcinatorQuality : 2/3.0 * (toolQuality + calcinatorQuality) + 0.5); + break; + + case 2: + + quality = negative ? 1+toolQuality : (magnitude && duration ? toolQuality : toolQuality + 0.5); + break; + + case 3: + + quality = magnitude && duration ? calcinatorQuality : calcinatorQuality + 0.5; + break; + } + + if (setup==3 || !negative) + { + value += quality; + } + else + { + if (quality==0) + throw std::runtime_error ("invalid derived alchemy apparatus quality"); + + value /= quality; + } +} + +void MWMechanics::Alchemy::updateEffects() +{ + mEffects.clear(); + + int ingredients = 0; + + for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) + if (!iter->isEmpty()) + ++ingredients; + + if (ingredients<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty()) + return; + + // find effects + std::set<EffectKey> effects (listEffects()); + filterEffects (effects); + + // general alchemy factor + float x = getChance(); + + x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->base->mData.mQuality; + x *= MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionStrengthMult")->getFloat(); + + // build quantified effect list + for (std::set<EffectKey>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter) + { + const ESM::MagicEffect *magicEffect = + MWBase::Environment::get().getWorld()->getStore().magicEffects.find (iter->mId); + + if (magicEffect->mData.mBaseCost<=0) + throw std::runtime_error ("invalid base cost for magic effect " + iter->mId); + + float fPotionT1MagMul = + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1MagMul")->getFloat(); + + if (fPotionT1MagMul<=0) + throw std::runtime_error ("invalid gmst: fPotionT1MagMul"); + + float fPotionT1DurMult = + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1DurMult")->getFloat(); + + if (fPotionT1DurMult<=0) + throw std::runtime_error ("invalid gmst: fPotionT1DurMult"); + + float magnitude = magicEffect->mData.mFlags && ESM::MagicEffect::NoMagnitude ? + 1 : (x / fPotionT1MagMul) / magicEffect->mData.mBaseCost; + float duration = magicEffect->mData.mFlags && ESM::MagicEffect::NoDuration ? + 1 : (x / fPotionT1DurMult) / magicEffect->mData.mBaseCost; + + if (!(magicEffect->mData.mFlags && ESM::MagicEffect::NoMagnitude)) + applyTools (magicEffect->mData.mFlags, magnitude); + + if (!(magicEffect->mData.mFlags && ESM::MagicEffect::NoDuration)) + applyTools (magicEffect->mData.mFlags, duration); + + duration = static_cast<int> (duration+0.5); + magnitude = static_cast<int> (magnitude+0.5); + + if (magnitude>0 && duration>0) + { + ESM::ENAMstruct effect; + effect.mEffectID = iter->mId; + + effect.mSkill = effect.mAttribute = iter->mArg; // somewhat hack-ish, but should work + + effect.mRange = 0; + effect.mArea = 0; + + effect.mDuration = duration; + effect.mMagnMin = effect.mMagnMax = magnitude; + + mEffects.push_back (effect); + } + } +} + +const ESM::Potion *MWMechanics::Alchemy::getRecord() const +{ + +} + +void MWMechanics::Alchemy::removeIngredients() +{ + +} + +void MWMechanics::Alchemy::addPotion (const std::string& name) +{ + +} + +void MWMechanics::Alchemy::increaseSkill() +{ + +} + +float MWMechanics::Alchemy::getChance() const +{ + const CreatureStats& creatureStats = MWWorld::Class::get (mAlchemist).getCreatureStats (mAlchemist); + const NpcStats& npcStats = MWWorld::Class::get (mAlchemist).getNpcStats (mAlchemist); + + return + (npcStats.getSkill (ESM::Skill::Alchemy).getModified() + + 0.1 * creatureStats.getAttribute (1).getModified() + + 0.1 * creatureStats.getAttribute (7).getModified()); +} void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) { - mNpc = npc; + mAlchemist = npc; mIngredients.resize (4); @@ -19,6 +263,8 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) std::fill (mTools.begin(), mTools.end(), MWWorld::Ptr()); + mEffects.clear(); + MWWorld::ContainerStore& store = MWWorld::Class::get (npc).getContainerStore (npc); for (MWWorld::ContainerStoreIterator iter (store.begin (MWWorld::ContainerStore::Type_Apparatus)); @@ -61,9 +307,10 @@ MWMechanics::Alchemy::TIngredientsIterator MWMechanics::Alchemy::endIngredients( void MWMechanics::Alchemy::clear() { - mNpc = MWWorld::Ptr(); + mAlchemist = MWWorld::Ptr(); mTools.clear(); mIngredients.clear(); + mEffects.clear(); } int MWMechanics::Alchemy::addIngredient (const MWWorld::Ptr& ingredient) @@ -86,6 +333,8 @@ int MWMechanics::Alchemy::addIngredient (const MWWorld::Ptr& ingredient) return -1; mIngredients[slot] = ingredient; + + updateEffects(); return slot; } @@ -93,6 +342,61 @@ int MWMechanics::Alchemy::addIngredient (const MWWorld::Ptr& ingredient) void MWMechanics::Alchemy::removeIngredient (int index) { if (index>=0 && index<static_cast<int> (mIngredients.size())) + { mIngredients[index] = MWWorld::Ptr(); + updateEffects(); + } } +MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::beginEffects() const +{ + return mEffects.begin(); +} + +MWMechanics::Alchemy::TEffectsIterator MWMechanics::Alchemy::endEffects() const +{ + return mEffects.end(); +} + +std::string MWMechanics::Alchemy::getPotionName() const +{ + if (const ESM::Potion *potion = getRecord()) + return potion->mName; + + return ""; +} + +MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& name) +{ + if (mTools[ESM::Apparatus::MortarPestle].isEmpty()) + return Result_NoMortarAndPestle; + + int ingredients = 0; + + for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) + if (!iter->isEmpty()) + ++ingredients; + + if (ingredients<2) + return Result_LessThanTwoIngredients; + + if (name.empty() && getPotionName().empty()) + return Result_NoName; + + if (beginEffects()==endEffects()) + return Result_NoEffects; + + if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100) + { + removeIngredients(); + return Result_RandomFailure; + } + + addPotion (name); + + removeIngredients(); + + increaseSkill(); + + return Result_Success; +} diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 7c3cf9e680..73fa7eb188 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -2,11 +2,16 @@ #define GAME_MWMECHANICS_ALCHEMY_H #include <vector> +#include <set> + +#include <components/esm/effectlist.hpp> #include "../mwworld/ptr.hpp" namespace MWMechanics { + struct EffectKey; + /// \brief Potion creation via alchemy skill class Alchemy { @@ -17,13 +22,54 @@ namespace MWMechanics typedef std::vector<MWWorld::Ptr> TIngredientsContainer; typedef TIngredientsContainer::const_iterator TIngredientsIterator; + + typedef std::vector<ESM::ENAMstruct> TEffectsContainer; + typedef TEffectsContainer::const_iterator TEffectsIterator; + + enum Result + { + Result_Success, + + Result_NoMortarAndPestle, + Result_LessThanTwoIngredients, + Result_NoName, + Result_NoEffects, + Result_RandomFailure + }; private: - MWWorld::Ptr mNpc; + MWWorld::Ptr mAlchemist; TToolsContainer mTools; TIngredientsContainer mIngredients; + TEffectsContainer mEffects; + std::set<EffectKey> listEffects() const; + ///< List all effects of all used ingredients. + + void filterEffects (std::set<EffectKey>& effects) const; + ///< Filter out effects not shared by all ingredients. + + void applyTools (int flags, float& value) const; + + void updateEffects(); + + const ESM::Potion *getRecord() const; + ///< Return existing recrod for created potion (may return 0) + + void removeIngredients(); + ///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and + /// update effect list accordingly. + + void addPotion (const std::string& name); + ///< Add a potion to the alchemist's inventory. + + void increaseSkill(); + ///< Increase alchemist's skill. + + float getChance() const; + ///< Return chance of success. + public: void setAlchemist (const MWWorld::Ptr& npc); @@ -49,6 +95,20 @@ namespace MWMechanics void removeIngredient (int index); ///< Remove ingredient from slot (calling this function on an empty slot is a no-op). + + TEffectsIterator beginEffects() const; + + TEffectsIterator endEffects() const; + + std::string getPotionName() const; + ///< Return the name of the potion that would be created when calling create (if a record for such + /// a potion already exists) or return an empty string. + + Result create (const std::string& name); + ///< Try to create a potion from the ingredients, place it in the inventory of the alchemist and + /// adjust the skills of the alchemist accordingly. + /// \param name must not be an empty string, unless there is already a potion record ( + /// getPotionName() does not return an empty string). }; } diff --git a/components/esm/loadmgef.hpp b/components/esm/loadmgef.hpp index 861f66be05..a763576c3c 100644 --- a/components/esm/loadmgef.hpp +++ b/components/esm/loadmgef.hpp @@ -14,6 +14,8 @@ struct MagicEffect enum Flags { NoDuration = 0x4, + NoMagnitude = 0x8, + Negative2 = 0x10, SpellMaking = 0x0200, Enchanting = 0x0400, Negative = 0x0800 // A harmful effect. Will determine whether From 3fe0a73cf24349a8a8abff9c27724dda9812e330 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 18 Oct 2012 14:38:38 +0200 Subject: [PATCH 050/255] Issue #61: increase alchemy skill on successful potion creation --- apps/openmw/mwmechanics/alchemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index bf39afefbc..3a5efbaaf6 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -237,7 +237,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name) void MWMechanics::Alchemy::increaseSkill() { - + MWWorld::Class::get (mAlchemist).skillUsageSucceeded (mAlchemist, ESM::Skill::Alchemy, 0); } float MWMechanics::Alchemy::getChance() const From 3c71378fade9b52cd011034425aa7c585f818444 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 18 Oct 2012 14:41:57 +0200 Subject: [PATCH 051/255] Issue 61: improved ingredients handling in alchemy and documenation --- apps/openmw/mwmechanics/alchemy.cpp | 29 ++++++++++++++--------------- apps/openmw/mwmechanics/alchemy.hpp | 4 ++++ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 3a5efbaaf6..d59d713064 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -148,13 +148,7 @@ void MWMechanics::Alchemy::updateEffects() { mEffects.clear(); - int ingredients = 0; - - for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) - if (!iter->isEmpty()) - ++ingredients; - - if (ingredients<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty()) + if (countIngredients()<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty()) return; // find effects @@ -251,6 +245,17 @@ float MWMechanics::Alchemy::getChance() const + 0.1 * creatureStats.getAttribute (7).getModified()); } +int MWMechanics::Alchemy::countIngredients() const +{ + int ingredients = 0; + + for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) + if (!iter->isEmpty()) + ++ingredients; + + return ingredients; +} + void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) { mAlchemist = npc; @@ -370,14 +375,8 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na { if (mTools[ESM::Apparatus::MortarPestle].isEmpty()) return Result_NoMortarAndPestle; - - int ingredients = 0; - - for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) - if (!iter->isEmpty()) - ++ingredients; - - if (ingredients<2) + + if (countIngredients()<2) return Result_LessThanTwoIngredients; if (name.empty() && getPotionName().empty()) diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 73fa7eb188..52af29912e 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -70,6 +70,8 @@ namespace MWMechanics float getChance() const; ///< Return chance of success. + int countIngredients() const; + public: void setAlchemist (const MWWorld::Ptr& npc); @@ -77,10 +79,12 @@ namespace MWMechanics /// there is no alchemist (alchemy session has ended). TToolsIterator beginTools() const; + ///< \attention Iterates over tool slots, not over tools. Some of the slots may be empty. TToolsIterator endTools() const; TIngredientsIterator beginIngredients() const; + ///< \attention Iterates over ingredient slots, not over ingredients. Some of the slots may be empty. TIngredientsIterator endIngredients() const; From f5caf227b23e602dba92da031648c78eeee84450 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 18 Oct 2012 14:47:23 +0200 Subject: [PATCH 052/255] Issue #61: remove ingredients on potion creation --- apps/openmw/mwmechanics/alchemy.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index d59d713064..f59d87ae7a 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -221,7 +221,21 @@ const ESM::Potion *MWMechanics::Alchemy::getRecord() const void MWMechanics::Alchemy::removeIngredients() { - + bool needsUpdate = false; + + for (TIngredientsContainer::iterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter) + if (!iter->isEmpty()) + { + iter->getRefData().setCount (iter->getRefData().getCount()-1); + if (iter->getRefData().getCount()<1) + { + needsUpdate = true; + *iter = MWWorld::Ptr(); + } + } + + if (needsUpdate) + updateEffects(); } void MWMechanics::Alchemy::addPotion (const std::string& name) From 1864dbe0311da194b720c92da4fb9f4b91f91743 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 18 Oct 2012 15:33:27 +0200 Subject: [PATCH 053/255] Issue #61: potion creation --- apps/openmw/mwmechanics/alchemy.cpp | 72 +++++++++++++++++++++++++++++ apps/openmw/mwmechanics/alchemy.hpp | 1 + 2 files changed, 73 insertions(+) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index f59d87ae7a..e37a302108 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -1,6 +1,7 @@ #include "alchemy.hpp" +#include <cassert> #include <cstdlib> #include <algorithm> @@ -19,6 +20,7 @@ #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" #include "../mwworld/cellstore.hpp" +#include "../mwworld/manualref.hpp" #include "magiceffects.hpp" #include "creaturestats.hpp" @@ -147,6 +149,7 @@ void MWMechanics::Alchemy::applyTools (int flags, float& value) const void MWMechanics::Alchemy::updateEffects() { mEffects.clear(); + mValue = 0; if (countIngredients()<2 || mAlchemist.isEmpty() || mTools[ESM::Apparatus::MortarPestle].isEmpty()) return; @@ -161,6 +164,10 @@ void MWMechanics::Alchemy::updateEffects() x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->base->mData.mQuality; x *= MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionStrengthMult")->getFloat(); + // value + mValue = static_cast<int> ( + x * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("iAlchemyMod")->getFloat()); + // build quantified effect list for (std::set<EffectKey>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter) { @@ -216,7 +223,39 @@ void MWMechanics::Alchemy::updateEffects() const ESM::Potion *MWMechanics::Alchemy::getRecord() const { + for (ESMS::RecListWithIDT<ESM::Potion>::MapType::const_iterator iter ( + MWBase::Environment::get().getWorld()->getStore().potions.list.begin()); + iter!=MWBase::Environment::get().getWorld()->getStore().potions.list.end(); ++iter) + { + if (iter->second.mEffects.mList.size()!=mEffects.size()) + continue; + + bool mismatch = false; + for (int i=0; i<static_cast<int> (iter->second.mEffects.mList.size()); ++iter) + { + const ESM::ENAMstruct& first = iter->second.mEffects.mList[i]; + const ESM::ENAMstruct& second = mEffects[i]; + + if (first.mEffectID!=second.mEffectID || + first.mArea!=second.mArea || + first.mRange!=second.mRange || + first.mSkill!=second.mSkill || + first.mAttribute!=second.mAttribute || + first.mMagnMin!=second.mMagnMin || + first.mMagnMax!=second.mMagnMax || + first.mDuration!=second.mDuration) + { + mismatch = true; + break; + } + } + + if (!mismatch) + return &iter->second; + } + + return 0; } void MWMechanics::Alchemy::removeIngredients() @@ -240,7 +279,40 @@ void MWMechanics::Alchemy::removeIngredients() void MWMechanics::Alchemy::addPotion (const std::string& name) { + const ESM::Potion *record = getRecord(); + + if (!record) + { + ESM::Potion newRecord; + + newRecord.mData.mWeight = 0; + + for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) + if (!iter->isEmpty()) + newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->base->mData.mWeight; + + newRecord.mData.mWeight /= countIngredients(); + + newRecord.mData.mValue = mValue; + newRecord.mData.mAutoCalc = 0; + + newRecord.mName = name; + int index = static_cast<int> (std::rand()/static_cast<double> (RAND_MAX)*6); + assert (index>=0 && index<6); + + static const char *name[] = { "standard", "bargain", "cheap", "fresh", "exclusive", "quality" }; + + newRecord.mModel = "m\\misc_potion_" + std::string (name[index]) + "_01.nif"; + newRecord.mIcon = "m\\tx_potion_" + std::string (name[index]) + "_01.dds"; + + newRecord.mEffects.mList = mEffects; + + record = MWBase::Environment::get().getWorld()->createRecord (newRecord).second; + } + + MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId); + MWWorld::Class::get (mAlchemist).getContainerStore (mAlchemist).add (ref.getPtr()); } void MWMechanics::Alchemy::increaseSkill() diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 52af29912e..7f3e2c0eaa 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -43,6 +43,7 @@ namespace MWMechanics TToolsContainer mTools; TIngredientsContainer mIngredients; TEffectsContainer mEffects; + int mValue; std::set<EffectKey> listEffects() const; ///< List all effects of all used ingredients. From 28cc480ce1d4175d54c1971d2449c0066c27d23a Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 18 Oct 2012 22:21:39 +0200 Subject: [PATCH 054/255] fix some alchemy issues and make the gui use the new implementation --- apps/openmw/engine.cpp | 15 +- apps/openmw/mwgui/alchemywindow.cpp | 204 +++++----------------------- apps/openmw/mwgui/alchemywindow.hpp | 12 +- apps/openmw/mwgui/tooltips.cpp | 10 +- apps/openmw/mwmechanics/alchemy.cpp | 15 +- apps/openmw/mwworld/worldimp.cpp | 18 +-- 6 files changed, 58 insertions(+), 216 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index adbfca129d..3867cb76a5 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -424,21 +424,10 @@ void OMW::Engine::activate() if (handle.empty()) return; - // the faced handle is not updated immediately, so on a cell change it might - // point to an object that doesn't exist anymore - // therefore, we are catching the "Unknown Ogre handle" exception that occurs in this case - MWWorld::Ptr ptr; - try - { - ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); - if (ptr.isEmpty()) - return; - } - catch (std::runtime_error&) - { + if (ptr.isEmpty()) return; - } MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr); diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index cef5d6e2e7..192bbd0901 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -70,142 +70,44 @@ namespace MWGui void AlchemyWindow::onCreateButtonClicked(MyGUI::Widget* _sender) { + std::string name = mNameEdit->getCaption(); + boost::algorithm::trim(name); + + MWMechanics::Alchemy::Result result = mAlchemy.create (mNameEdit->getCaption ()); + + if (result == MWMechanics::Alchemy::Result_NoName) + { + mWindowManager.messageBox("#{sNotifyMessage37}", std::vector<std::string>()); + return; + } + // check if mortar & pestle is available (always needed) - /// \todo check albemic, calcinator, retort (sometimes needed) - if (!mApparatus[0]->isUserString("ToolTipType")) + if (result == MWMechanics::Alchemy::Result_NoMortarAndPestle) { mWindowManager.messageBox("#{sNotifyMessage45}", std::vector<std::string>()); return; } // make sure 2 or more ingredients were selected - int numIngreds = 0; - for (int i=0; i<4; ++i) - if (mIngredients[i]->isUserString("ToolTipType")) - ++numIngreds; - - if (numIngreds < 2) + if (result == MWMechanics::Alchemy::Result_LessThanTwoIngredients) { mWindowManager.messageBox("#{sNotifyMessage6a}", std::vector<std::string>()); return; } - // make sure a name was entered - std::string name = mNameEdit->getCaption(); - boost::algorithm::trim(name); - if (name == "") - { - mWindowManager.messageBox("#{sNotifyMessage37}", std::vector<std::string>()); - return; - } - - // if there are no created effects, the potion will always fail (but the ingredients won't be destroyed) - if (mEffects.empty()) + if (result == MWMechanics::Alchemy::Result_NoEffects) { mWindowManager.messageBox("#{sNotifyMessage8}", std::vector<std::string>()); MWBase::Environment::get().getSoundManager()->playSound("potion fail", 1.f, 1.f); return; } - if (rand() % 2 == 0) /// \todo + if (result == MWMechanics::Alchemy::Result_Success) { - ESM::Potion newPotion; - newPotion.mName = mNameEdit->getCaption(); - ESM::EffectList effects; - for (unsigned int i=0; i<4; ++i) - { - if (mEffects.size() >= i+1) - { - ESM::ENAMstruct effect; - effect.mEffectID = mEffects[i].mEffectID; - effect.mArea = 0; - effect.mRange = ESM::RT_Self; - effect.mSkill = mEffects[i].mSkill; - effect.mAttribute = mEffects[i].mAttribute; - effect.mMagnMin = 1; /// \todo - effect.mMagnMax = 10; /// \todo - effect.mDuration = 60; /// \todo - effects.mList.push_back(effect); - } - } - - // UESP Wiki / Morrowind:Alchemy - // "The weight of a potion is an average of the weight of the ingredients, rounded down." - // note by scrawl: not rounding down here, I can't imagine a created potion to - // have 0 weight when using ingredients with 0.1 weight respectively - float weight = 0; - for (int i=0; i<4; ++i) - if (mIngredients[i]->isUserString("ToolTipType")) - weight += mIngredients[i]->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>()->base->mData.mWeight; - newPotion.mData.mWeight = weight / float(numIngreds); - - newPotion.mData.mValue = 100; /// \todo - newPotion.mEffects = effects; - // pick a random mesh and icon - std::vector<std::string> names; - /// \todo is the mesh/icon dependent on alchemy skill? - names.push_back("standard"); - names.push_back("bargain"); - names.push_back("cheap"); - names.push_back("fresh"); - names.push_back("exclusive"); - names.push_back("quality"); - int random = rand() % names.size(); - newPotion.mModel = "m\\misc_potion_" + names[random ] + "_01.nif"; - newPotion.mIcon = "m\\tx_potion_" + names[random ] + "_01.dds"; - - // check if a similiar potion record exists already - bool found = false; - std::string objectId; - typedef std::map<std::string, ESM::Potion> PotionMap; - PotionMap potions = MWBase::Environment::get().getWorld()->getStore().potions.list; - for (PotionMap::const_iterator it = potions.begin(); it != potions.end(); ++it) - { - if (found) break; - - if (it->second.mData.mValue == newPotion.mData.mValue - && it->second.mData.mWeight == newPotion.mData.mWeight - && it->second.mName == newPotion.mName - && it->second.mEffects.mList.size() == newPotion.mEffects.mList.size()) - { - // check effects - for (unsigned int i=0; i < it->second.mEffects.mList.size(); ++i) - { - const ESM::ENAMstruct& a = it->second.mEffects.mList[i]; - const ESM::ENAMstruct& b = newPotion.mEffects.mList[i]; - if (a.mEffectID == b.mEffectID - && a.mArea == b.mArea - && a.mRange == b.mRange - && a.mSkill == b.mSkill - && a.mAttribute == b.mAttribute - && a.mMagnMin == b.mMagnMin - && a.mMagnMax == b.mMagnMax - && a.mDuration == b.mDuration) - { - found = true; - objectId = it->first; - break; - } - } - } - } - - if (!found) - { - std::pair<std::string, const ESM::Potion*> result = MWBase::Environment::get().getWorld()->createRecord(newPotion); - objectId = result.first; - } - - // create a reference and add it to player inventory - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), objectId); - MWWorld::ContainerStore& store = MWWorld::Class::get(mPtr).getContainerStore(mPtr); - ref.getPtr().getRefData().setCount(1); - store.add(ref.getPtr()); - mWindowManager.messageBox("#{sPotionSuccess}", std::vector<std::string>()); MWBase::Environment::get().getSoundManager()->playSound("potion success", 1.f, 1.f); } - else + else if (result == MWMechanics::Alchemy::Result_RandomFailure) { // potion failed mWindowManager.messageBox("#{sNotifyMessage8}", std::vector<std::string>()); @@ -229,7 +131,7 @@ namespace MWGui { openContainer (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr setFilter (ContainerBase::Filter_Ingredients); - + mAlchemy.setAlchemist (mPtr); int index = 0; @@ -277,6 +179,9 @@ namespace MWGui if (!mIngredients[i]->isUserString("ToolTipType")) { add = mIngredients[i]; + + mAlchemy.addIngredient(item); + break; } @@ -306,8 +211,6 @@ namespace MWGui void AlchemyWindow::update() { - Widgets::SpellEffectList effects; - for (int i=0; i<4; ++i) { MyGUI::ImageBox* ingredient = mIngredients[i]; @@ -315,19 +218,6 @@ namespace MWGui if (!ingredient->isUserString("ToolTipType")) continue; - // add the effects of this ingredient to list of effects - MWWorld::LiveCellRef<ESM::Ingredient>* ref = ingredient->getUserData<MWWorld::Ptr>()->get<ESM::Ingredient>(); - for (int i=0; i<4; ++i) - { - if (ref->base->mData.mEffectID[i] < 0) - continue; - MWGui::Widgets::SpellEffectParams params; - params.mEffectID = ref->base->mData.mEffectID[i]; - params.mAttribute = ref->base->mData.mAttributes[i]; - params.mSkill = ref->base->mData.mSkills[i]; - effects.push_back(params); - } - // update ingredient count labels if (ingredient->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0)); @@ -340,50 +230,14 @@ namespace MWGui text->setCaption(getCountString(ingredient->getUserData<MWWorld::Ptr>()->getRefData().getCount())); } - // now remove effects that are only present once - Widgets::SpellEffectList::iterator it = effects.begin(); - while (it != effects.end()) + std::vector<ESM::ENAMstruct> effects; + ESM::EffectList list; + list.mList = effects; + for (MWMechanics::Alchemy::TEffectsIterator it = mAlchemy.beginEffects (); it != mAlchemy.endEffects (); ++it) { - Widgets::SpellEffectList::iterator next = it; - ++next; - bool found = false; - for (; next != effects.end(); ++next) - { - if (*next == *it) - found = true; - } - - if (!found) - it = effects.erase(it); - else - ++it; + list.mList.push_back(*it); } - // now remove duplicates, and don't allow more than 4 effects - Widgets::SpellEffectList old = effects; - effects.clear(); - int i=0; - for (Widgets::SpellEffectList::iterator it = old.begin(); - it != old.end(); ++it) - { - bool found = false; - for (Widgets::SpellEffectList::iterator it2 = effects.begin(); - it2 != effects.end(); ++it2) - { - // MW considers all "foritfy attribute" effects as the same effect. See the - // "Can't create multi-state boost potions" discussion on http://www.uesp.net/wiki/Morrowind_talk:Alchemy - // thus, we are only checking effectID here and not attribute or skill - if (it2->mEffectID == it->mEffectID) - found = true; - } - if (!found && i<4) - { - ++i; - effects.push_back(*it); - } - } - mEffects = effects; - while (mEffectsBox->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(mEffectsBox->getChildAt(0)); @@ -391,7 +245,9 @@ namespace MWGui Widgets::MWEffectListPtr effectsWidget = mEffectsBox->createWidget<Widgets::MWEffectList> ("MW_StatName", coord, MyGUI::Align::Left | MyGUI::Align::Top); effectsWidget->setWindowManager(&mWindowManager); - effectsWidget->setEffectList(effects); + + Widgets::SpellEffectList _list = Widgets::MWEffectList::effectListFromESM(&list); + effectsWidget->setEffectList(_list); std::vector<MyGUI::WidgetPtr> effectItems; effectsWidget->createEffectWidgets(effectItems, mEffectsBox, coord, false, 0); @@ -404,5 +260,9 @@ namespace MWGui static_cast<MyGUI::ImageBox*>(ingredient)->setImageTexture(""); if (ingredient->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0)); + + for (int i=0; i<4; ++i) + if (mIngredients[i] == ingredient) + mAlchemy.removeIngredient (i); } } diff --git a/apps/openmw/mwgui/alchemywindow.hpp b/apps/openmw/mwgui/alchemywindow.hpp index 179cdd174f..5f84e73e9b 100644 --- a/apps/openmw/mwgui/alchemywindow.hpp +++ b/apps/openmw/mwgui/alchemywindow.hpp @@ -26,8 +26,6 @@ namespace MWGui MyGUI::EditBox* mNameEdit; - Widgets::SpellEffectList mEffects; // effects of created potion - void onCancelButtonClicked(MyGUI::Widget* _sender); void onCreateButtonClicked(MyGUI::Widget* _sender); void onIngredientSelected(MyGUI::Widget* _sender); @@ -41,12 +39,12 @@ namespace MWGui void update(); - private: - - MWMechanics::Alchemy mAlchemy; + private: - std::vector<MyGUI::ImageBox *> mApparatus; - std::vector<MyGUI::ImageBox *> mIngredients; + MWMechanics::Alchemy mAlchemy; + + std::vector<MyGUI::ImageBox *> mApparatus; + std::vector<MyGUI::ImageBox *> mIngredients; }; } diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 39afba7497..5256028ebb 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -79,14 +79,10 @@ void ToolTips::onFrame(float frameDuration) || (mWindowManager->getMode() == GM_Inventory))) { std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); - try - { - mFocusObject = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle); - } - catch (std::exception /* & e */) - { + + mFocusObject = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle); + if (mFocusObject.isEmpty ()) return; - } MyGUI::IntSize tooltipSize = getToolTipViaPtr(true); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index e37a302108..583a3c18e6 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -62,6 +62,9 @@ void MWMechanics::Alchemy::filterEffects (std::set<EffectKey>& effects) const { bool found = false; + if (iter->isEmpty()) + continue; + const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>(); for (int i=0; i<4; ++i) @@ -178,7 +181,7 @@ void MWMechanics::Alchemy::updateEffects() throw std::runtime_error ("invalid base cost for magic effect " + iter->mId); float fPotionT1MagMul = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1MagMul")->getFloat(); + MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1MagMult")->getFloat(); if (fPotionT1MagMul<=0) throw std::runtime_error ("invalid gmst: fPotionT1MagMul"); @@ -189,15 +192,15 @@ void MWMechanics::Alchemy::updateEffects() if (fPotionT1DurMult<=0) throw std::runtime_error ("invalid gmst: fPotionT1DurMult"); - float magnitude = magicEffect->mData.mFlags && ESM::MagicEffect::NoMagnitude ? + float magnitude = magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude ? 1 : (x / fPotionT1MagMul) / magicEffect->mData.mBaseCost; - float duration = magicEffect->mData.mFlags && ESM::MagicEffect::NoDuration ? + float duration = magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration ? 1 : (x / fPotionT1DurMult) / magicEffect->mData.mBaseCost; - if (!(magicEffect->mData.mFlags && ESM::MagicEffect::NoMagnitude)) + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoMagnitude)) applyTools (magicEffect->mData.mFlags, magnitude); - if (!(magicEffect->mData.mFlags && ESM::MagicEffect::NoDuration)) + if (!(magicEffect->mData.mFlags & ESM::MagicEffect::NoDuration)) applyTools (magicEffect->mData.mFlags, duration); duration = static_cast<int> (duration+0.5); @@ -471,7 +474,7 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na if (beginEffects()==endEffects()) return Result_NoEffects; - if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100) + if (getChance()<std::rand()/static_cast<double> (RAND_MAX)) { removeIngredients(); return Result_RandomFailure; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 6fc228f0b5..8d8542bb58 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -339,7 +339,7 @@ namespace MWWorld return ptr; } - throw std::runtime_error ("unknown Ogre handle: " + handle); + return MWWorld::Ptr(); } void World::enable (const Ptr& reference) @@ -850,12 +850,13 @@ namespace MWWorld mWeatherManager->update (duration); // inform the GUI about focused object - try - { - MWWorld::Ptr object = getPtrViaHandle(mFacedHandle); - MWBase::Environment::get().getWindowManager()->setFocusObject(object); + MWWorld::Ptr object = getPtrViaHandle(mFacedHandle); - // retrieve object dimensions so we know where to place the floating label + MWBase::Environment::get().getWindowManager()->setFocusObject(object); + + // retrieve object dimensions so we know where to place the floating label + if (!object.isEmpty ()) + { Ogre::SceneNode* node = object.getRefData().getBaseNode(); Ogre::AxisAlignedBox bounds; int i; @@ -871,11 +872,6 @@ namespace MWWorld screenCoords[0], screenCoords[1], screenCoords[2], screenCoords[3]); } } - catch (std::runtime_error&) - { - MWWorld::Ptr null; - MWBase::Environment::get().getWindowManager()->setFocusObject(null); - } if (!mRendering->occlusionQuerySupported()) { From 3f833af46a442e2aa08bdfbab71f39b510848505 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 19 Oct 2012 10:07:27 +0200 Subject: [PATCH 055/255] Issue #407: Fortyfy attribute effects were ignored for the last 3 attributes --- apps/openmw/mwmechanics/actors.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 87a0583948..ab332eb960 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -118,18 +118,14 @@ namespace MWMechanics + fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified ()); } } - - - } - void Actors::calculateCreatureStatModifiers (const MWWorld::Ptr& ptr) { CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); // attributes - for (int i=0; i<5; ++i) + for (int i=0; i<8; ++i) { int modifier = creatureStats.getMagicEffects().get (EffectKey (79, i)).mMagnitude; From bdca5aff879665aabe13ca923cab28b5791a60b3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 19 Oct 2012 13:10:06 +0200 Subject: [PATCH 056/255] Issue #68: simplified the dynamic stats interface --- apps/openmw/mwclass/creature.cpp | 6 +-- apps/openmw/mwclass/npc.cpp | 6 +-- apps/openmw/mwmechanics/actors.cpp | 54 ++++++++++++------- apps/openmw/mwmechanics/creaturestats.cpp | 25 ++++----- apps/openmw/mwmechanics/creaturestats.hpp | 14 ++--- .../mwmechanics/mechanicsmanagerimp.cpp | 10 ++-- apps/openmw/mwscript/statsextensions.cpp | 27 +++++++--- 7 files changed, 78 insertions(+), 64 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0cf348b14d..0fb9daf195 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -55,9 +55,9 @@ namespace MWClass data->mCreatureStats.getAttribute(5).set (ref->base->mData.mEndurance); data->mCreatureStats.getAttribute(6).set (ref->base->mData.mPersonality); data->mCreatureStats.getAttribute(7).set (ref->base->mData.mLuck); - data->mCreatureStats.getHealth().set (ref->base->mData.mHealth); - data->mCreatureStats.getMagicka().set (ref->base->mData.mMana); - data->mCreatureStats.getFatigue().set (ref->base->mData.mFatigue); + data->mCreatureStats.setHealth (ref->base->mData.mHealth); + data->mCreatureStats.setMagicka (ref->base->mData.mMana); + data->mCreatureStats.setFatigue (ref->base->mData.mFatigue); data->mCreatureStats.setLevel(ref->base->mData.mLevel); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 03b5e56aa4..7e7e4937bf 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -89,9 +89,9 @@ namespace MWClass data->mCreatureStats.getAttribute(5).set (ref->base->mNpdt52.mEndurance); data->mCreatureStats.getAttribute(6).set (ref->base->mNpdt52.mPersonality); data->mCreatureStats.getAttribute(7).set (ref->base->mNpdt52.mLuck); - data->mCreatureStats.getHealth().set (ref->base->mNpdt52.mHealth); - data->mCreatureStats.getMagicka().set (ref->base->mNpdt52.mMana); - data->mCreatureStats.getFatigue().set (ref->base->mNpdt52.mFatigue); + data->mCreatureStats.setHealth (ref->base->mNpdt52.mHealth); + data->mCreatureStats.setMagicka (ref->base->mNpdt52.mMana); + data->mCreatureStats.setFatigue (ref->base->mNpdt52.mFatigue); data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); } diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index ab332eb960..43d9e8a3b7 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -73,13 +73,17 @@ namespace MWMechanics double magickaFactor = creatureStats.getMagicEffects().get (EffectKey (84)).mMagnitude * 0.1 + 0.5; - creatureStats.getHealth().setBase( - static_cast<int> (0.5 * (strength + endurance)) + creatureStats.getLevelHealthBonus ()); + DynamicStat<float> health = creatureStats.getHealth(); + health.setBase (static_cast<int> (0.5 * (strength + endurance)) + creatureStats.getLevelHealthBonus ()); + creatureStats.setHealth (health); - creatureStats.getMagicka().setBase( - static_cast<int> (intelligence + magickaFactor * intelligence)); - - creatureStats.getFatigue().setBase(strength+willpower+agility+endurance); + DynamicStat<float> magicka = creatureStats.getMagicka(); + magicka.setBase (static_cast<int> (intelligence + magickaFactor * intelligence)); + creatureStats.setMagicka (magicka); + + DynamicStat<float> fatigue = creatureStats.getFatigue(); + fatigue.setBase (strength+willpower+agility+endurance); + creatureStats.setFatigue (fatigue); } void Actors::calculateRestoration (const MWWorld::Ptr& ptr, float duration) @@ -92,8 +96,10 @@ namespace MWMechanics bool stunted = stats.getMagicEffects ().get(MWMechanics::EffectKey(136)).mMagnitude > 0; int endurance = stats.getAttribute (ESM::Attribute::Endurance).getModified (); - stats.getHealth().setCurrent(stats.getHealth ().getCurrent () - + 0.1 * endurance); + + DynamicStat<float> health = stats.getHealth(); + health.setCurrent (health.getCurrent() + 0.1 * endurance); + stats.setHealth (health); const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); @@ -109,13 +115,19 @@ namespace MWMechanics float x = fFatigueReturnBase + fFatigueReturnMult * (1 - normalizedEncumbrance); x *= fEndFatigueMult * endurance; - stats.getFatigue ().setCurrent (stats.getFatigue ().getCurrent () + 3600 * x); - + + DynamicStat<float> fatigue = stats.getFatigue(); + fatigue.setCurrent (fatigue.getCurrent() + 3600 * x); + stats.setFatigue (fatigue); + if (!stunted) { float fRestMagicMult = store.gameSettings.find("fRestMagicMult")->getFloat (); - stats.getMagicka().setCurrent (stats.getMagicka ().getCurrent () - + fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified ()); + + DynamicStat<float> magicka = stats.getMagicka(); + magicka.setCurrent (magicka.getCurrent() + + fRestMagicMult * stats.getAttribute(ESM::Attribute::Intelligence).getModified()); + stats.setMagicka (magicka); } } } @@ -137,14 +149,16 @@ namespace MWMechanics // dynamic stats MagicEffects effects = creatureStats.getMagicEffects(); - creatureStats.getHealth().setModifier( - effects.get(EffectKey(80)).mMagnitude - effects.get(EffectKey(18)).mMagnitude); - - creatureStats.getMagicka().setModifier( - effects.get(EffectKey(81)).mMagnitude - effects.get(EffectKey(19)).mMagnitude); - - creatureStats.getFatigue().setModifier( - effects.get(EffectKey(82)).mMagnitude - effects.get(EffectKey(20)).mMagnitude); + + for (int i=0; i<3; ++i) + { + DynamicStat<float> stat = creatureStats.getDynamic (i); + + stat.setModifier ( + effects.get (EffectKey(80+i)).mMagnitude - effects.get (EffectKey(18+i)).mMagnitude); + + creatureStats.setDynamic (i, stat); + } } Actors::Actors() : mDuration (0) {} diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index fc05231412..4f699bba0f 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -118,22 +118,7 @@ namespace MWMechanics return mAttributes[index]; } - DynamicStat<float> &CreatureStats::getHealth() - { - return mDynamic[0]; - } - - DynamicStat<float> &CreatureStats::getMagicka() - { - return mDynamic[1]; - } - - DynamicStat<float> &CreatureStats::getFatigue() - { - return mDynamic[2]; - } - - DynamicStat<float> &CreatureStats::getDynamic(int index) + const DynamicStat<float> &CreatureStats::getDynamic(int index) const { if (index < 0 || index > 2) { throw std::runtime_error("dynamic stat index is out of range"); @@ -184,6 +169,14 @@ namespace MWMechanics mDynamic[2] = value; } + void CreatureStats::setDynamic (int index, const DynamicStat<float> &value) + { + if (index < 0 || index > 2) + throw std::runtime_error("dynamic stat index is out of range"); + + mDynamic[index] = value; + } + void CreatureStats::setLevel(int level) { mLevel = level; diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 7a1e46f56e..82988ce8b4 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -43,6 +43,8 @@ namespace MWMechanics const DynamicStat<float> & getFatigue() const; + const DynamicStat<float> & getDynamic (int index) const; + const Spells & getSpells() const; const ActiveSpells & getActiveSpells() const; @@ -59,24 +61,14 @@ namespace MWMechanics int getAlarm() const; - Stat<int> & getAttribute(int index); - DynamicStat<float> & getHealth(); - - DynamicStat<float> & getMagicka(); - - DynamicStat<float> & getFatigue(); - - DynamicStat<float> & getDynamic(int index); - Spells & getSpells(); ActiveSpells & getActiveSpells(); MagicEffects & getMagicEffects(); - void setAttribute(int index, const Stat<int> &value); void setHealth(const DynamicStat<float> &value); @@ -85,6 +77,8 @@ namespace MWMechanics void setFatigue(const DynamicStat<float> &value); + void setDynamic (int index, const DynamicStat<float> &value); + void setSpells(const Spells &spells); void setActiveSpells(const ActiveSpells &active); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 364e653217..6d8bdb3321 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -153,12 +153,14 @@ namespace MWMechanics // forced update and current value adjustments mActors.updateActor (ptr, 0); - creatureStats.getHealth().setCurrent(creatureStats.getHealth().getModified()); - creatureStats.getMagicka().setCurrent(creatureStats.getMagicka().getModified()); - creatureStats.getFatigue().setCurrent(creatureStats.getFatigue().getModified()); + for (int i=0; i<2; ++i) + { + DynamicStat<float> stat = creatureStats.getDynamic (i); + stat.setCurrent (stat.getModified()); + creatureStats.setDynamic (i, stat); + } } - MechanicsManager::MechanicsManager() : mUpdatePlayer (true), mClassSelected (false), mRaceSelected (false) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 66a5acae0a..11548feab1 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -188,10 +188,12 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get(ptr) - .getCreatureStats(ptr) - .getDynamic(mIndex) - .setModified(value, 0); + MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr) + .getDynamic (mIndex)); + + stat.setModified (value, 0); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat); } }; @@ -215,10 +217,14 @@ namespace MWScript Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent(); - stats.getDynamic(mIndex).setModified( - diff + stats.getDynamic(mIndex).getModified(), 0); + MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr) + .getDynamic (mIndex)); - stats.getDynamic(mIndex).setCurrent(diff + current); + stat.setModified (diff + stat.getModified(), 0); + + stat.setCurrent (diff + current); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat); } }; @@ -242,7 +248,12 @@ namespace MWScript Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent(); - stats.getDynamic(mIndex).setCurrent (diff + current); + MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr) + .getDynamic (mIndex)); + + stat.setCurrent (diff + current); + + MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat); } }; From a8f294c9ae88efcc487f4a260cd0a056bcabb8e0 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 19 Oct 2012 18:01:45 +0200 Subject: [PATCH 057/255] fixed types of dynamic stats script instructions --- apps/openmw/mwscript/statsextensions.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 11548feab1..fc57bb6545 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -155,7 +155,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer value; + Interpreter::Type_Float value; if (mIndex==0 && MWWorld::Class::get (ptr).hasItemHealth (ptr)) { @@ -185,7 +185,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer value = runtime[0].mInteger; + Interpreter::Type_Float value = runtime[0].mFloat; runtime.pop(); MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr) @@ -210,12 +210,12 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer diff = runtime[0].mInteger; + Interpreter::Type_Float diff = runtime[0].mFloat; runtime.pop(); MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr); - Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent(); + Interpreter::Type_Float current = stats.getDynamic(mIndex).getCurrent(); MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr) .getDynamic (mIndex)); @@ -241,12 +241,12 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - Interpreter::Type_Integer diff = runtime[0].mInteger; + Interpreter::Type_Float diff = runtime[0].mFloat; runtime.pop(); MWMechanics::CreatureStats& stats = MWWorld::Class::get (ptr).getCreatureStats (ptr); - Interpreter::Type_Integer current = stats.getDynamic(mIndex).getCurrent(); + Interpreter::Type_Float current = stats.getDynamic(mIndex).getCurrent(); MWMechanics::DynamicStat<float> stat (MWWorld::Class::get (ptr).getCreatureStats (ptr) .getDynamic (mIndex)); @@ -687,16 +687,16 @@ namespace MWScript for (int i=0; i<numberOfDynamics; ++i) { - extensions.registerFunction (get + dynamics[i], 'l', "", + extensions.registerFunction (get + dynamics[i], 'f', "", opcodeGetDynamic+i, opcodeGetDynamicExplicit+i); - extensions.registerInstruction (set + dynamics[i], "l", + extensions.registerInstruction (set + dynamics[i], "f", opcodeSetDynamic+i, opcodeSetDynamicExplicit+i); - extensions.registerInstruction (mod + dynamics[i], "l", + extensions.registerInstruction (mod + dynamics[i], "f", opcodeModDynamic+i, opcodeModDynamicExplicit+i); - extensions.registerInstruction (modCurrent + dynamics[i], "l", + extensions.registerInstruction (modCurrent + dynamics[i], "f", opcodeModCurrentDynamic+i, opcodeModCurrentDynamicExplicit+i); extensions.registerFunction (get + dynamics[i] + getRatio, 'f', "", From 7884a927c96bafa1158a0d19772e0c45a35ca86c Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 19 Oct 2012 18:56:22 +0200 Subject: [PATCH 058/255] Issue #68: added dead flag to CreatureStats --- apps/openmw/mwmechanics/creaturestats.cpp | 28 +++++++++++++++++++---- apps/openmw/mwmechanics/creaturestats.hpp | 6 ++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 4f699bba0f..1ce7bdb93a 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -10,7 +10,7 @@ namespace MWMechanics { CreatureStats::CreatureStats() - : mLevelHealthBonus(0.f) + : mLevel (0), mHello (0), mFight (0), mFlee (0), mAlarm (0), mLevelHealthBonus(0.f), mDead (false) { } @@ -156,17 +156,17 @@ namespace MWMechanics void CreatureStats::setHealth(const DynamicStat<float> &value) { - mDynamic[0] = value; + setDynamic (0, value); } void CreatureStats::setMagicka(const DynamicStat<float> &value) { - mDynamic[1] = value; + setDynamic (1, value); } void CreatureStats::setFatigue(const DynamicStat<float> &value) { - mDynamic[2] = value; + setDynamic (2, value); } void CreatureStats::setDynamic (int index, const DynamicStat<float> &value) @@ -175,6 +175,9 @@ namespace MWMechanics throw std::runtime_error("dynamic stat index is out of range"); mDynamic[index] = value; + + if (index==2 && mDynamic[index].getCurrent()<1) + mDead = true; } void CreatureStats::setLevel(int level) @@ -211,4 +214,21 @@ namespace MWMechanics { mAlarm = value; } + + bool CreatureStats::isDead() const + { + return mDead; + } + + void CreatureStats::resurrect() + { + if (mDead) + { + if (mDynamic[0].getCurrent()<1) + mDynamic[0].setCurrent (1); + + if (mDynamic[0].getCurrent()>=1) + mDead = false; + } + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 82988ce8b4..671dcd4396 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -29,8 +29,8 @@ namespace MWMechanics int mFlee; int mAlarm; AiSequence mAiSequence; - float mLevelHealthBonus; + bool mDead; public: CreatureStats(); @@ -105,6 +105,10 @@ namespace MWMechanics // small hack to allow the fact that Health permanently increases by 10% of endurance on each level up void increaseLevelHealthBonus(float value); float getLevelHealthBonus() const; + + bool isDead() const; + + void resurrect(); }; } From d76522e7a48ed83c659e782d81bfdbe44ca761a1 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 19 Oct 2012 19:48:02 +0200 Subject: [PATCH 059/255] searchPtrViaHandle --- apps/openmw/engine.cpp | 2 +- apps/openmw/mwbase/world.hpp | 3 +++ apps/openmw/mwgui/hud.cpp | 10 +--------- apps/openmw/mwgui/tooltips.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 10 +++++++++- apps/openmw/mwworld/worldimp.hpp | 3 +++ 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 3867cb76a5..2ce8903631 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -424,7 +424,7 @@ void OMW::Engine::activate() if (handle.empty()) return; - MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPtrViaHandle (handle); + MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->searchPtrViaHandle (handle); if (ptr.isEmpty()) return; diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 521bbb988e..9dcdc312f1 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -142,6 +142,9 @@ namespace MWBase virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0; ///< Return a pointer to a liveCellRef with the given Ogre handle. + virtual MWWorld::Ptr searchPtrViaHandle (const std::string& handle) = 0; + ///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found + /// \todo enable reference in the OGRE scene virtual void enable (const MWWorld::Ptr& ptr) = 0; diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index ed0e592269..66cc6b21ad 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -245,15 +245,7 @@ void HUD::onWorldClicked(MyGUI::Widget* _sender) return; std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); - MWWorld::Ptr object; - try - { - object = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle); - } - catch (std::exception& /* e */) - { - return; - } + MWWorld::Ptr object = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle); if (mode == GM_Console) MWBase::Environment::get().getWindowManager()->getConsole()->setSelectedObject(object); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 5256028ebb..35224613ce 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -80,7 +80,7 @@ void ToolTips::onFrame(float frameDuration) { std::string handle = MWBase::Environment::get().getWorld()->getFacedHandle(); - mFocusObject = MWBase::Environment::get().getWorld()->getPtrViaHandle(handle); + mFocusObject = MWBase::Environment::get().getWorld()->searchPtrViaHandle(handle); if (mFocusObject.isEmpty ()) return; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8d8542bb58..2e3d80aa42 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -326,6 +326,14 @@ namespace MWWorld } Ptr World::getPtrViaHandle (const std::string& handle) + { + Ptr res = searchPtrViaHandle (handle); + if (res.isEmpty ()) + throw std::runtime_error ("unknown Ogre handle: " + handle); + return res; + } + + Ptr World::searchPtrViaHandle (const std::string& handle) { if (mPlayer->getPlayer().getRefData().getHandle()==handle) return mPlayer->getPlayer(); @@ -850,7 +858,7 @@ namespace MWWorld mWeatherManager->update (duration); // inform the GUI about focused object - MWWorld::Ptr object = getPtrViaHandle(mFacedHandle); + MWWorld::Ptr object = searchPtrViaHandle(mFacedHandle); MWBase::Environment::get().getWindowManager()->setFocusObject(object); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 90cd2151b6..f94882c102 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -163,6 +163,9 @@ namespace MWWorld virtual Ptr getPtrViaHandle (const std::string& handle); ///< Return a pointer to a liveCellRef with the given Ogre handle. + virtual Ptr searchPtrViaHandle (const std::string& handle); + ///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found + virtual void enable (const Ptr& ptr); virtual void disable (const Ptr& ptr); From 8d7514e341f4cd2c554507ea8c6c64772fec9714 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 19 Oct 2012 19:48:54 +0200 Subject: [PATCH 060/255] corrected chance --- apps/openmw/mwmechanics/alchemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 583a3c18e6..df7c786b1e 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -474,7 +474,7 @@ MWMechanics::Alchemy::Result MWMechanics::Alchemy::create (const std::string& na if (beginEffects()==endEffects()) return Result_NoEffects; - if (getChance()<std::rand()/static_cast<double> (RAND_MAX)) + if (getChance()<std::rand()/static_cast<double> (RAND_MAX)*100) { removeIngredients(); return Result_RandomFailure; From fbe3538f3263ee711f70aac8233009235e8c9f7e Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 19 Oct 2012 20:13:37 +0200 Subject: [PATCH 061/255] bug #412: sort birth signs --- apps/openmw/mwgui/birth.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index c8ef35be39..284653aee3 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -14,6 +14,16 @@ using namespace MWGui; using namespace Widgets; +namespace +{ + +bool sortBirthSigns(const std::pair<std::string, const ESM::BirthSign*>& left, const std::pair<std::string, const ESM::BirthSign*>& right) +{ + return left.second->mName.compare (right.second->mName) < 0; +} + +} + BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_chargen_birth.layout", parWindowManager) { @@ -115,11 +125,21 @@ void BirthDialog::updateBirths() ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); int index = 0; - for (; it != end; ++it) + + // sort by name + std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns; + for (; it!=end; ++it) { - const ESM::BirthSign &birth = it->second; - mBirthList->addItem(birth.mName, it->first); - if (boost::iequals(it->first, mCurrentBirthId)) + std::string id = it->first; + const ESM::BirthSign* sign = &it->second; + birthSigns.push_back(std::make_pair(id, sign)); + } + std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); + + for (std::vector < std::pair<std::string, const ESM::BirthSign*> >::const_iterator it2 = birthSigns.begin(); it2 != birthSigns.end(); ++it2) + { + mBirthList->addItem(it2->second->mName, it2->first); + if (boost::iequals(it2->first, mCurrentBirthId)) mBirthList->setIndexSelected(index); ++index; } From b2b92547187d46fc71ca5249ae1e4a69a16d8d76 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 19 Oct 2012 20:44:53 +0200 Subject: [PATCH 062/255] improved the ingredient GUI code (this didnt fix anything, though) --- apps/openmw/mwgui/alchemywindow.cpp | 60 +++++++++-------------------- 1 file changed, 19 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 192bbd0901..bda76490bc 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -151,46 +151,15 @@ namespace MWGui void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender) { removeIngredient(_sender); - drawItems(); update(); } void AlchemyWindow::onSelectedItemImpl(MWWorld::Ptr item) { - MyGUI::ImageBox* add = NULL; + int res = mAlchemy.addIngredient(item); - // don't allow to add an ingredient that is already added - // (which could happen if two similiar ingredients don't stack because of script / owner) - bool alreadyAdded = false; - std::string name = MWWorld::Class::get(item).getName(item); - for (int i=0; i<4; ++i) - if (mIngredients[i]->isUserString("ToolTipType")) - { - MWWorld::Ptr item2 = *mIngredients[i]->getUserData<MWWorld::Ptr>(); - std::string name2 = MWWorld::Class::get(item2).getName(item2); - if (name == name2) - alreadyAdded = true; - } - - if (alreadyAdded) - return; - - for (int i=0; i<4; ++i) - if (!mIngredients[i]->isUserString("ToolTipType")) - { - add = mIngredients[i]; - - mAlchemy.addIngredient(item); - - break; - } - - if (add != NULL) + if (res != -1) { - add->setUserString("ToolTipType", "ItemPtr"); - add->setUserData(item); - add->setImageTexture(getIconPath(item)); - drawItems(); update(); std::string sound = MWWorld::Class::get(item).getUpSoundId(item); @@ -211,17 +180,27 @@ namespace MWGui void AlchemyWindow::update() { + MWMechanics::Alchemy::TIngredientsIterator it = mAlchemy.beginIngredients (); for (int i=0; i<4; ++i) { MyGUI::ImageBox* ingredient = mIngredients[i]; - if (!ingredient->isUserString("ToolTipType")) - continue; + MWWorld::Ptr item = *it; + ++it; - // update ingredient count labels if (ingredient->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0)); + ingredient->setImageTexture(""); + ingredient->clearUserStrings (); + + if (item.isEmpty ()) + continue; + + ingredient->setUserString("ToolTipType", "ItemPtr"); + ingredient->setUserData(item); + ingredient->setImageTexture(getIconPath(item)); + MyGUI::TextBox* text = ingredient->createWidget<MyGUI::TextBox>("SandBrightText", MyGUI::IntCoord(0, 14, 32, 18), MyGUI::Align::Default, std::string("Label")); text->setTextAlign(MyGUI::Align::Right); text->setNeedMouseFocus(false); @@ -230,6 +209,8 @@ namespace MWGui text->setCaption(getCountString(ingredient->getUserData<MWWorld::Ptr>()->getRefData().getCount())); } + drawItems(); + std::vector<ESM::ENAMstruct> effects; ESM::EffectList list; list.mList = effects; @@ -256,13 +237,10 @@ namespace MWGui void AlchemyWindow::removeIngredient(MyGUI::Widget* ingredient) { - ingredient->clearUserStrings(); - static_cast<MyGUI::ImageBox*>(ingredient)->setImageTexture(""); - if (ingredient->getChildCount()) - MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0)); - for (int i=0; i<4; ++i) if (mIngredients[i] == ingredient) mAlchemy.removeIngredient (i); + + update(); } } From 59560e84eb18b8376f383d0b7411b885108de3fe Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 19 Oct 2012 20:48:15 +0200 Subject: [PATCH 063/255] small addition --- apps/openmw/mwgui/alchemywindow.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index bda76490bc..56db47a0f5 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -146,6 +146,8 @@ namespace MWGui mApparatus.at (index)->setImageTexture (getIconPath (*iter)); } } + + update(); } void AlchemyWindow::onIngredientSelected(MyGUI::Widget* _sender) @@ -185,8 +187,12 @@ namespace MWGui { MyGUI::ImageBox* ingredient = mIngredients[i]; - MWWorld::Ptr item = *it; - ++it; + MWWorld::Ptr item; + if (it != mAlchemy.endIngredients ()) + { + item = *it; + ++it; + } if (ingredient->getChildCount()) MyGUI::Gui::getInstance().destroyWidget(ingredient->getChildAt(0)); From f2e25b8a476a2fad5c35d29c7e894bd716a110f3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 20 Oct 2012 10:49:48 +0200 Subject: [PATCH 064/255] Issue #68: Keep dead actors out of the actor list for the current scene --- apps/openmw/mwbase/mechanicsmanager.hpp | 2 ++ apps/openmw/mwmechanics/actors.cpp | 3 ++- apps/openmw/mwmechanics/actors.hpp | 2 ++ apps/openmw/mwmechanics/mechanicsmanagerimp.hpp | 2 ++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 39d7e6e1a4..c5d721e264 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -39,6 +39,8 @@ namespace MWBase virtual void addActor (const MWWorld::Ptr& ptr) = 0; ///< Register an actor for stats management + /// + /// \note Dead actors are ignored. virtual void removeActor (const MWWorld::Ptr& ptr) = 0; ///< Deregister an actor for stats management diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 43d9e8a3b7..63f890d65d 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -165,7 +165,8 @@ namespace MWMechanics void Actors::addActor (const MWWorld::Ptr& ptr) { - mActors.insert (ptr); + if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead()) + mActors.insert (ptr); } void Actors::removeActor (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index 7e5a0ac861..f8a00f3492 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -40,6 +40,8 @@ namespace MWMechanics void addActor (const MWWorld::Ptr& ptr); ///< Register an actor for stats management + /// + /// \note Dead actors are ignored. void removeActor (const MWWorld::Ptr& ptr); ///< Deregister an actor for stats management diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 3a41e8fa60..205deaf714 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -41,6 +41,8 @@ namespace MWMechanics virtual void addActor (const MWWorld::Ptr& ptr); ///< Register an actor for stats management + /// + /// \note Dead actors are ignored. virtual void removeActor (const MWWorld::Ptr& ptr); ///< Deregister an actor for stats management From 0547f11564efec3fc719d64d0f859478eb0d9450 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 20 Oct 2012 10:54:51 +0200 Subject: [PATCH 065/255] Issue #68: Remove dead actors from actor list --- apps/openmw/mwmechanics/actors.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 63f890d65d..a33ef7240c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -199,13 +199,23 @@ namespace MWMechanics { float totalDuration = mDuration; mDuration = 0; + + std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); - for (std::set<MWWorld::Ptr>::iterator iter (mActors.begin()); iter!=mActors.end(); ++iter) + while (iter!=mActors.end()) { - updateActor (*iter, totalDuration); + if (!MWWorld::Class::get (*iter).getCreatureStats (*iter).isDead()) + { + updateActor (*iter, totalDuration); - if (iter->getTypeName()==typeid (ESM::NPC).name()) - updateNpc (*iter, totalDuration, paused); + if (iter->getTypeName()==typeid (ESM::NPC).name()) + updateNpc (*iter, totalDuration, paused); + } + + if (MWWorld::Class::get (*iter).getCreatureStats (*iter).isDead()) + mActors.erase (iter++); + else + ++iter; } } From 6433b1e0220fe08baff1e242fa2a6cd463f79002 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Mon, 22 Oct 2012 02:25:10 +0200 Subject: [PATCH 066/255] Some minor fixes --- apps/launcher/datafilespage.cpp | 3 ++- apps/launcher/maindialog.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index c0a447e263..ebbfb99600 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -90,6 +90,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) // Set the row height to the size of the checkboxes mMastersTable->verticalHeader()->setDefaultSectionSize(height); + mMastersTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); mMastersTable->verticalHeader()->hide(); mMastersTable->setColumnHidden(1, true); mMastersTable->setColumnHidden(2, true); @@ -110,7 +111,7 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) mPluginsTable->setAlternatingRowColors(true); mPluginsTable->setVerticalScrollMode(QAbstractItemView::ScrollPerItem); mPluginsTable->horizontalHeader()->setStretchLastSection(true); - + mPluginsTable->horizontalHeader()->hide(); mPluginsTable->verticalHeader()->setDefaultSectionSize(height); mPluginsTable->verticalHeader()->setResizeMode(QHeaderView::Fixed); mPluginsTable->setColumnHidden(1, true); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index f7dafd3af5..3ce418ddf8 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -244,10 +244,10 @@ void MainDialog::play() const std::string settingspath = (mCfgMgr.getUserPath() / "settings.cfg").string(); mSettings.saveUser(settingspath); -#ifdef Q_WS_WIN +#ifdef Q_OS_WIN QString game = "./openmw.exe"; QFile file(game); -#elif defined(Q_WS_MAC) +#elif defined(Q_OS_MAC) QDir dir(QCoreApplication::applicationDirPath()); QString game = dir.absoluteFilePath("openmw"); QFile file(game); From 9f821e5df20370da3eb3c39f24a69e05c96cdc3b Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@scrawl-laptop.(none)> Date: Mon, 22 Oct 2012 16:56:43 +0200 Subject: [PATCH 067/255] fix shaders --- files/materials/objects.shader | 15 ++++++++++++--- files/materials/terrain.shader | 12 ++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/files/materials/objects.shader b/files/materials/objects.shader index 525e4ab636..5ea076342e 100644 --- a/files/materials/objects.shader +++ b/files/materials/objects.shader @@ -157,10 +157,15 @@ shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart) #endif -#if UNDERWATER +#if (UNDERWATER) || (FOG) shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix) - shUniform(float, waterLevel) @shSharedParameter(waterLevel) shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position) +#endif + +#if UNDERWATER + + shUniform(float, waterLevel) @shSharedParameter(waterLevel) + shUniform(float4, lightDirectionWS0) @shAutoConstant(lightDirectionWS0, light_position, 0) shSampler2D(causticMap) @@ -211,8 +216,12 @@ float3 caustics = float3(1,1,1); -#if UNDERWATER + +#if (UNDERWATER) || (FOG) float3 worldPos = shMatrixMult(worldMatrix, float4(objSpacePositionPassthrough,1)).xyz; +#endif + +#if UNDERWATER float3 waterEyePos = float3(1,1,1); // NOTE: this calculation would be wrong for non-uniform scaling float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0)); diff --git a/files/materials/terrain.shader b/files/materials/terrain.shader index 35ce403307..dee7332630 100644 --- a/files/materials/terrain.shader +++ b/files/materials/terrain.shader @@ -187,11 +187,13 @@ shUniform(float4, shadowFar_fadeStart) @shSharedParameter(shadowFar_fadeStart) #endif +#if (UNDERWATER) || (FOG) + shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix) + shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position) +#endif #if UNDERWATER - shUniform(float4x4, worldMatrix) @shAutoConstant(worldMatrix, world_matrix) shUniform(float, waterLevel) @shSharedParameter(waterLevel) - shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position) shUniform(float4, lightDirectionWS0) @shAutoConstant(lightDirectionWS0, light_position, 0) shSampler2D(causticMap) @@ -222,9 +224,12 @@ float3 caustics = float3(1,1,1); +#if (UNDERWATER) || (FOG) + float3 worldPos = shMatrixMult(worldMatrix, float4(objSpacePosition,1)).xyz; +#endif + #if UNDERWATER - float3 worldPos = shMatrixMult(worldMatrix, float4(objSpacePosition,1)).xyz; float3 waterEyePos = float3(1,1,1); // NOTE: this calculation would be wrong for non-uniform scaling float4 worldNormal = shMatrixMult(worldMatrix, float4(normal.xyz, 0)); @@ -373,7 +378,6 @@ shOutputColour(0).xyz = gammaCorrectOutput(shOutputColour(0).xyz); - #if MRT shOutputColour(1) = float4(depth / far,1,1,1); #endif From fe9120bcb31a7653e7cfd772c8ad4cfb51ce059f Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 23 Oct 2012 01:47:07 +0200 Subject: [PATCH 068/255] Added support for the profiles and made creation/editing them more user friendly --- apps/launcher/CMakeLists.txt | 9 +- apps/launcher/datafilespage.cpp | 146 ++++++++++++++++------- apps/launcher/datafilespage.hpp | 11 +- apps/launcher/main.cpp | 2 +- apps/launcher/maindialog.cpp | 2 - apps/launcher/utils/combobox.hpp | 28 ----- apps/launcher/utils/profilescombobox.cpp | 52 ++++++++ apps/launcher/utils/profilescombobox.hpp | 30 +++++ apps/launcher/utils/textinputdialog.cpp | 61 ++++++++++ apps/launcher/utils/textinputdialog.hpp | 28 +++++ 10 files changed, 289 insertions(+), 80 deletions(-) delete mode 100644 apps/launcher/utils/combobox.hpp create mode 100644 apps/launcher/utils/profilescombobox.cpp create mode 100644 apps/launcher/utils/profilescombobox.hpp create mode 100644 apps/launcher/utils/textinputdialog.cpp create mode 100644 apps/launcher/utils/textinputdialog.hpp diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 92903b48d7..edc3dcf32e 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -12,6 +12,8 @@ set(LAUNCHER utils/filedialog.cpp utils/naturalsort.cpp utils/lineedit.cpp + utils/profilescombobox.cpp + utils/textinputdialog.cpp launcher.rc ) @@ -26,10 +28,12 @@ set(LAUNCHER_HEADER model/modelitem.hpp model/esm/esmfile.hpp - utils/combobox.hpp utils/lineedit.hpp utils/filedialog.hpp utils/naturalsort.hpp + utils/profilescombobox.hpp + utils/textinputdialog.hpp + ) # Headers that must be pre-processed @@ -43,9 +47,10 @@ set(LAUNCHER_HEADER_MOC model/modelitem.hpp model/esm/esmfile.hpp - utils/combobox.hpp utils/lineedit.hpp utils/filedialog.hpp + utils/profilescombobox.hpp + utils/textinputdialog.hpp ) source_group(launcher FILES ${LAUNCHER} ${LAUNCHER_HEADER} ${LAUNCHER_HEADER_MOC}) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index ce3d6b31dd..01b8798426 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -6,10 +6,11 @@ #include "model/datafilesmodel.hpp" #include "model/esm/esmfile.hpp" -#include "utils/combobox.hpp" +#include "utils/profilescombobox.hpp" #include "utils/filedialog.hpp" #include "utils/lineedit.hpp" #include "utils/naturalsort.hpp" +#include "utils/textinputdialog.hpp" #include "datafilespage.hpp" @@ -139,9 +140,11 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) // Bottom part with profile options QLabel *profileLabel = new QLabel(tr("Current Profile: "), this); - mProfilesComboBox = new ComboBox(this); + mProfilesComboBox = new ProfilesComboBox(this); mProfilesComboBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum)); - mProfilesComboBox->setInsertPolicy(QComboBox::InsertAtBottom); + mProfilesComboBox->setInsertPolicy(QComboBox::NoInsert); + mProfilesComboBox->setDuplicatesEnabled(false); + mProfilesComboBox->setEditEnabled(false); mProfileToolBar = new QToolBar(this); mProfileToolBar->setMovable(false); @@ -156,16 +159,22 @@ DataFilesPage::DataFilesPage(Files::ConfigurationManager &cfg, QWidget *parent) pageLayout->addWidget(splitter); pageLayout->addWidget(mProfileToolBar); + // Create a dialog for the new profile name input + mNewProfileDialog = new TextInputDialog(tr("New Profile"), tr("Profile name:"), this); + + connect(mNewProfileDialog->lineEdit(), SIGNAL(textChanged(QString)), this, SLOT(updateOkButton(QString))); + connect(mPluginsTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mMastersTable, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(setCheckState(QModelIndex))); connect(mMastersModel, SIGNAL(checkedItemsChanged(QStringList,QStringList)), mPluginsModel, SLOT(slotcheckedItemsChanged(QStringList,QStringList))); - connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(const QString))); + connect(filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - connect(mPluginsTable, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); + connect(mPluginsTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); - connect(mProfilesComboBox, SIGNAL(textChanged(const QString&, const QString&)), this, SLOT(profileChanged(const QString&, const QString&))); + connect(mProfilesComboBox, SIGNAL(profileRenamed(QString,QString)), this, SLOT(profileRenamed(QString,QString))); + connect(mProfilesComboBox, SIGNAL(profileChanged(QString,QString)), this, SLOT(profileChanged(QString,QString))); createActions(); setupConfig(); @@ -230,12 +239,21 @@ void DataFilesPage::setupConfig() mLauncherConfig->beginGroup("Profiles"); QStringList profiles = mLauncherConfig->childGroups(); - if (profiles.isEmpty()) { - // Add a default profile - profiles.append("Default"); + // Add the profiles to the combobox + foreach (const QString &profile, profiles) { + + if (profile.contains(QRegExp("[^a-zA-Z0-9_]"))) + continue; // Profile name contains garbage + + + qDebug() << "adding " << profile; + mProfilesComboBox->addItem(profile); } - mProfilesComboBox->addItems(profiles); + // Add a default profile + if (mProfilesComboBox->count() == 0) { + mProfilesComboBox->addItem(QString("Default")); + } QString currentProfile = mLauncherConfig->value("CurrentProfile").toString(); @@ -572,33 +590,37 @@ void DataFilesPage::writeConfig(QString profile) void DataFilesPage::newProfile() { - bool ok; - QString text = QInputDialog::getText(this, tr("New Profile"), - tr("Profile Name:"), QLineEdit::Normal, - tr("New Profile"), &ok); - if (ok && !text.isEmpty()) { - if (mProfilesComboBox->findText(text) != -1) { - QMessageBox::warning(this, tr("Profile already exists"), - tr("the profile <b>%0</b> already exists.").arg(text), - QMessageBox::Ok); - } else { - // Add the new profile to the combobox - mProfilesComboBox->addItem(text); - mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); + if (mNewProfileDialog->exec() == QDialog::Accepted) { - } + const QString text = mNewProfileDialog->lineEdit()->text(); + mProfilesComboBox->addItem(text); + // Copy the currently checked items to cfg + writeConfig(text); + mLauncherConfig->sync(); + + mProfilesComboBox->setCurrentIndex(mProfilesComboBox->findText(text)); } } +void DataFilesPage::updateOkButton(const QString &text) +{ + if (text.isEmpty()) { + mNewProfileDialog->setOkButtonEnabled(false); + return; + } + + (mProfilesComboBox->findText(text) == -1) + ? mNewProfileDialog->setOkButtonEnabled(true) + : mNewProfileDialog->setOkButtonEnabled(false); +} + void DataFilesPage::deleteProfile() { QString profile = mProfilesComboBox->currentText(); - - if (profile.isEmpty()) { + if (profile.isEmpty()) return; - } QMessageBox msgBox(this); msgBox.setWindowTitle(tr("Delete Profile")); @@ -694,19 +716,17 @@ void DataFilesPage::setCheckState(QModelIndex index) return; if (object->objectName() == QLatin1String("PluginsTable")) { - if (mPluginsModel->checkState(index) == Qt::Checked) { - mPluginsModel->setCheckState(index, Qt::Unchecked); - } else { - mPluginsModel->setCheckState(index, Qt::Checked); - } + QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index); + + (mPluginsModel->checkState(sourceIndex) == Qt::Checked) + ? mPluginsModel->setCheckState(index, Qt::Unchecked) + : mPluginsModel->setCheckState(index, Qt::Checked); } if (object->objectName() == QLatin1String("MastersTable")) { - if (mMastersModel->checkState(index) == Qt::Checked) { - mMastersModel->setCheckState(index, Qt::Unchecked); - } else { - mMastersModel->setCheckState(index, Qt::Checked); - } + (mMastersModel->checkState(index) == Qt::Checked) + ? mMastersModel->setCheckState(index, Qt::Unchecked) + : mMastersModel->setCheckState(index, Qt::Checked); } return; @@ -721,13 +741,23 @@ void DataFilesPage::filterChanged(const QString filter) void DataFilesPage::profileChanged(const QString &previous, const QString ¤t) { + qDebug() << "Profile is changed from: " << previous << " to " << current; // Prevent the deletion of the default profile - (current == QLatin1String("Default")) ? mDeleteProfileAction->setEnabled(false) - : mDeleteProfileAction->setEnabled(true); + if (current == QLatin1String("Default")) { + mDeleteProfileAction->setEnabled(false); + mProfilesComboBox->setEditEnabled(false); + } else { + mDeleteProfileAction->setEnabled(true); + mProfilesComboBox->setEditEnabled(true); + } if (!previous.isEmpty()) { writeConfig(previous); mLauncherConfig->sync(); + + if (mProfilesComboBox->currentIndex() == -1) + return; + } else { return; } @@ -737,6 +767,36 @@ void DataFilesPage::profileChanged(const QString &previous, const QString &curre readConfig(); } +void DataFilesPage::profileRenamed(const QString &previous, const QString ¤t) +{ + if (previous.isEmpty()) + return; + + // Save the new profile name + writeConfig(current); + + // Make sure we have no groups open + while (!mLauncherConfig->group().isEmpty()) { + mLauncherConfig->endGroup(); + } + + mLauncherConfig->beginGroup("Profiles"); + + // Open the profile-name subgroup + mLauncherConfig->beginGroup(previous); + mLauncherConfig->remove(""); // Clear the subgroup + mLauncherConfig->endGroup(); + mLauncherConfig->endGroup(); + mLauncherConfig->sync(); + + // Remove the profile from the combobox + mProfilesComboBox->removeItem(mProfilesComboBox->findText(previous)); + + mMastersModel->uncheckAll(); + mPluginsModel->uncheckAll(); + readConfig(); +} + void DataFilesPage::showContextMenu(const QPoint &point) { // Make sure there are plugins in the view @@ -756,11 +816,9 @@ void DataFilesPage::showContextMenu(const QPoint &point) if (!index.isValid()) return; - if (mPluginsModel->checkState(index) == Qt::Checked) { - mUncheckAction->setEnabled(true); - } else { - mCheckAction->setEnabled(true); - } + (mPluginsModel->checkState(index) == Qt::Checked) + ? mUncheckAction->setEnabled(true) + : mCheckAction->setEnabled(true); } // Show menu diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 64f255b575..8b48c1e123 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -3,7 +3,7 @@ #include <QWidget> #include <QModelIndex> - +#include "utils/profilescombobox.hpp" #include <components/files/collections.hpp> @@ -13,9 +13,10 @@ class QSettings; class QAction; class QToolBar; class QMenu; -class ComboBox; +class ProfilesComboBox; class DataFilesModel; +class TextInputDialog; namespace Files { struct ConfigurationManager; } @@ -26,7 +27,7 @@ class DataFilesPage : public QWidget public: DataFilesPage(Files::ConfigurationManager& cfg, QWidget *parent = 0); - ComboBox *mProfilesComboBox; + ProfilesComboBox *mProfilesComboBox; void writeConfig(QString profile = QString()); bool setupDataFiles(); @@ -37,6 +38,8 @@ public slots: void filterChanged(const QString filter); void showContextMenu(const QPoint &point); void profileChanged(const QString &previous, const QString ¤t); + void profileRenamed(const QString &previous, const QString ¤t); + void updateOkButton(const QString &text); // Action slots void newProfile(); @@ -77,6 +80,8 @@ private: QSettings *mLauncherConfig; + TextInputDialog *mNewProfileDialog; + // const QStringList checkedPlugins(); // const QStringList selectedMasters(); diff --git a/apps/launcher/main.cpp b/apps/launcher/main.cpp index 4ae09f8447..7c4cb5f7e8 100644 --- a/apps/launcher/main.cpp +++ b/apps/launcher/main.cpp @@ -11,7 +11,7 @@ int main(int argc, char *argv[]) // Now we make sure the current dir is set to application path QDir dir(QCoreApplication::applicationDirPath()); - #if defined(Q_OS_MAC) + #ifdef Q_OS_MAC if (dir.dirName() == "MacOS") { dir.cdUp(); dir.cdUp(); diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index d65e51f24c..3ce418ddf8 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -1,7 +1,5 @@ #include <QtGui> -#include "utils/combobox.hpp" - #include "maindialog.hpp" #include "playpage.hpp" #include "graphicspage.hpp" diff --git a/apps/launcher/utils/combobox.hpp b/apps/launcher/utils/combobox.hpp deleted file mode 100644 index bc99575d74..0000000000 --- a/apps/launcher/utils/combobox.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef COMBOBOX_H -#define COMBOBOX_H - -#include <QComboBox> - -class ComboBox : public QComboBox -{ - Q_OBJECT -private: - QString oldText; -public: - ComboBox(QWidget *parent=0) : QComboBox(parent), oldText() - { - connect(this,SIGNAL(editTextChanged(const QString&)), this, - SLOT(textChangedSlot(const QString&))); - connect(this,SIGNAL(currentIndexChanged(const QString&)), this, - SLOT(textChangedSlot(const QString&))); - } -private slots: - void textChangedSlot(const QString &newText) - { - emit textChanged(oldText, newText); - oldText = newText; - } -signals: - void textChanged(const QString &oldText, const QString &newText); -}; -#endif \ No newline at end of file diff --git a/apps/launcher/utils/profilescombobox.cpp b/apps/launcher/utils/profilescombobox.cpp new file mode 100644 index 0000000000..8354d4a780 --- /dev/null +++ b/apps/launcher/utils/profilescombobox.cpp @@ -0,0 +1,52 @@ +#include <QRegExpValidator> +#include <QLineEdit> +#include <QString> + +#include "profilescombobox.hpp" + +ProfilesComboBox::ProfilesComboBox(QWidget *parent) : + QComboBox(parent) +{ + mValidator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore + + setEditable(true); + setValidator(mValidator); + setCompleter(0); + + connect(this, SIGNAL(currentIndexChanged(int)), this, + SLOT(slotIndexChanged(int))); + connect(lineEdit(), SIGNAL(returnPressed()), this, + SLOT(slotReturnPressed())); +} + +void ProfilesComboBox::setEditEnabled(bool editable) +{ + if (!editable) + return setEditable(false); + + // Reset the completer and validator + setEditable(true); + setValidator(mValidator); + setCompleter(0); +} + +void ProfilesComboBox::slotReturnPressed() +{ + QString current = currentText(); + QString previous = itemText(currentIndex()); + + if (findText(current) != -1) + return; + + setItemText(currentIndex(), current); + emit(profileRenamed(previous, current)); +} + +void ProfilesComboBox::slotIndexChanged(int index) +{ + if (index == -1) + return; + + emit(profileChanged(mOldProfile, currentText())); + mOldProfile = itemText(index); +} diff --git a/apps/launcher/utils/profilescombobox.hpp b/apps/launcher/utils/profilescombobox.hpp new file mode 100644 index 0000000000..c7da60d2a5 --- /dev/null +++ b/apps/launcher/utils/profilescombobox.hpp @@ -0,0 +1,30 @@ +#ifndef PROFILESCOMBOBOX_HPP +#define PROFILESCOMBOBOX_HPP + +#include <QComboBox> + +class QString; + +class QRegExpValidator; + +class ProfilesComboBox : public QComboBox +{ + Q_OBJECT +public: + explicit ProfilesComboBox(QWidget *parent = 0); + void setEditEnabled(bool editable); + +signals: + void profileChanged(const QString &previous, const QString ¤t); + void profileRenamed(const QString &oldName, const QString &newName); + +private slots: + void slotReturnPressed(); + void slotIndexChanged(int index); + +private: + QString mOldProfile; + QRegExpValidator *mValidator; +}; + +#endif // PROFILESCOMBOBOX_HPP diff --git a/apps/launcher/utils/textinputdialog.cpp b/apps/launcher/utils/textinputdialog.cpp new file mode 100644 index 0000000000..16cadb6619 --- /dev/null +++ b/apps/launcher/utils/textinputdialog.cpp @@ -0,0 +1,61 @@ +#include <QDialogButtonBox> +#include <QPushButton> +#include <QDebug> +#include <QLabel> +#include <QVBoxLayout> +#include <QValidator> + +#include "lineedit.hpp" + +#include "textinputdialog.hpp" + +TextInputDialog::TextInputDialog(const QString& title, const QString &text, QWidget *parent) : + QDialog(parent) +{ + setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); + mButtonBox = new QDialogButtonBox(this); + mButtonBox->addButton(QDialogButtonBox::Ok); + mButtonBox->addButton(QDialogButtonBox::Cancel); + + setMaximumHeight(height()); + setOkButtonEnabled(false); + setModal(true); + + // Messageboxes on mac have no title +#ifndef Q_OS_MAC + setWindowTitle(title); +#else + Q_UNUSED(title); +#endif + + QLabel *label = new QLabel(this); + label->setText(text); + + // Line edit + QValidator *validator = new QRegExpValidator(QRegExp("^[a-zA-Z0-9_]*$"), this); // Alpha-numeric + underscore + mLineEdit = new LineEdit(this); + mLineEdit->setValidator(validator); + mLineEdit->setCompleter(0); + + QVBoxLayout *dialogLayout = new QVBoxLayout(this); + dialogLayout->addWidget(label); + dialogLayout->addWidget(mLineEdit); + dialogLayout->addWidget(mButtonBox); + + connect(mButtonBox, SIGNAL(accepted()), this, SLOT(accept())); + connect(mButtonBox, SIGNAL(rejected()), this, SLOT(reject())); +} + +int TextInputDialog::exec() +{ + mLineEdit->clear(); + mLineEdit->setFocus(); + return QDialog::exec(); +} + +void TextInputDialog::setOkButtonEnabled(bool enabled) +{ + + QPushButton *okButton = mButtonBox->button(QDialogButtonBox::Ok); + okButton->setEnabled(enabled); +} diff --git a/apps/launcher/utils/textinputdialog.hpp b/apps/launcher/utils/textinputdialog.hpp new file mode 100644 index 0000000000..cbb453ac83 --- /dev/null +++ b/apps/launcher/utils/textinputdialog.hpp @@ -0,0 +1,28 @@ +#ifndef TEXTINPUTDIALOG_HPP +#define TEXTINPUTDIALOG_HPP + +#include <QDialog> +//#include "lineedit.hpp" + +class QDialogButtonBox; +class LineEdit; + +class TextInputDialog : public QDialog +{ + Q_OBJECT +public: + explicit TextInputDialog(const QString& title, const QString &text, QWidget *parent = 0); + inline LineEdit *lineEdit() { return mLineEdit; } + void setOkButtonEnabled(bool enabled); + + LineEdit *mLineEdit; + + int exec(); + +private: + QDialogButtonBox *mButtonBox; + + +}; + +#endif // TEXTINPUTDIALOG_HPP From 234716daa6fca5d0f92069fdf19a03e67cd2b9a9 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 23 Oct 2012 11:42:38 +0200 Subject: [PATCH 069/255] finished spell creation --- apps/openmw/mwgui/spellcreationdialog.cpp | 77 +++++++++++++++++-- apps/openmw/mwgui/spellcreationdialog.hpp | 4 + apps/openmw/mwmechanics/spellsuccess.hpp | 26 +++++-- .../mygui/openmw_spellcreation_dialog.layout | 3 - 4 files changed, 93 insertions(+), 17 deletions(-) diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index bb066e8ffe..4ce0560108 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -15,10 +15,14 @@ #include "../mwmechanics/spells.hpp" #include "../mwmechanics/creaturestats.hpp" +#include "../mwmechanics/spellsuccess.hpp" + #include "tooltips.hpp" #include "widgets.hpp" #include "class.hpp" +#include "inventorywindow.hpp" +#include "tradewindow.hpp" namespace { @@ -310,14 +314,25 @@ namespace MWGui return; } - ESM::Spell newSpell; - ESM::EffectList effectList; - effectList.mList = mEffects; - newSpell.mEffects = effectList; - newSpell.mName = mNameEdit->getCaption(); - newSpell.mData.mType = ESM::Spell::ST_Spell; + if (mMagickaCost->getCaption() == "0") + { + mWindowManager.messageBox ("#{sEnchantmentMenu8}", std::vector<std::string>()); + return; + } - std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(newSpell); + if (boost::lexical_cast<int>(mPriceLabel->getCaption()) > mWindowManager.getInventoryWindow()->getPlayerGold()) + { + mWindowManager.messageBox ("#{sNotifyMessage18}", std::vector<std::string>()); + return; + } + + mSpell.mName = mNameEdit->getCaption(); + + mWindowManager.getTradeWindow()->addOrRemoveGold(-boost::lexical_cast<int>(mPriceLabel->getCaption())); + + MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); + + std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(mSpell); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); @@ -340,6 +355,47 @@ namespace MWGui mWindowManager.removeGuiMode (GM_SpellCreation); } + void SpellCreationDialog::notifyEffectsChanged () + { + float y = 0; + + for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) + { + float x = 0.5 * it->mMagnMin + it->mMagnMax; + + const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); + x *= 0.1 * effect->mData.mBaseCost; + x *= 1 + it->mDuration; + x += 0.05 * std::max(1, it->mArea) * effect->mData.mBaseCost; + + float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fEffectCostMult")->getFloat(); + y += x * fEffectCostMult; + y = std::max(1.f,y); + + if (effect->mData.mFlags & ESM::MagicEffect::CastTarget) + y *= 1.5; + } + + mSpell.mData.mCost = int(y); + + ESM::EffectList effectList; + effectList.mList = mEffects; + mSpell.mEffects = effectList; + mSpell.mData.mType = ESM::Spell::ST_Spell; + + mMagickaCost->setCaption(boost::lexical_cast<std::string>(int(y))); + + float fSpellMakingValueMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellMakingValueMult")->getFloat(); + + /// \todo mercantile + int price = int(y) * fSpellMakingValueMult; + + mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price))); + + float chance = MWMechanics::getSpellSuccessChance(&mSpell, MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); + mSuccessChance->setCaption(boost::lexical_cast<std::string>(int(chance))); + } + // ------------------------------------------------------------------------------------------------ @@ -443,6 +499,11 @@ namespace MWGui void EffectEditorBase::onAvailableEffectClicked (MyGUI::Widget* sender) { + if (mEffects.size() >= 8) + { + MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage28}", std::vector<std::string>()); + return; + } short effectId = *sender->getUserData<short>(); @@ -534,6 +595,8 @@ namespace MWGui } mUsedEffectsView->setCanvasSize(size); + + notifyEffectsChanged(); } void EffectEditorBase::onEffectAdded (ESM::ENAMstruct effect) diff --git a/apps/openmw/mwgui/spellcreationdialog.hpp b/apps/openmw/mwgui/spellcreationdialog.hpp index 255b04cf6e..4d27ec1c6f 100644 --- a/apps/openmw/mwgui/spellcreationdialog.hpp +++ b/apps/openmw/mwgui/spellcreationdialog.hpp @@ -116,6 +116,7 @@ namespace MWGui void startEditing(); void setWidgets (Widgets::MWList* availableEffectsList, MyGUI::ScrollView* usedEffectsView); + virtual void notifyEffectsChanged () {} }; class SpellCreationDialog : public WindowBase, public ReferenceInterface, public EffectEditorBase @@ -133,6 +134,7 @@ namespace MWGui void onCancelButtonClicked (MyGUI::Widget* sender); void onBuyButtonClicked (MyGUI::Widget* sender); + virtual void notifyEffectsChanged (); MyGUI::EditBox* mNameEdit; MyGUI::TextBox* mMagickaCost; @@ -143,6 +145,8 @@ namespace MWGui Widgets::MWEffectList* mUsedEffectsList; + ESM::Spell mSpell; + }; } diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index 43db42aab1..a46667cdc4 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -27,9 +27,8 @@ namespace MWMechanics return schoolSkillMap[school]; } - inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor) + inline int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor); // determine the spell's school @@ -60,27 +59,34 @@ namespace MWMechanics return school; } + inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor) + { + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + return getSpellSchool(spell, actor); + } + // UESP wiki / Morrowind/Spells: // Chance of success is (Spell's skill * 2 + Willpower / 5 + Luck / 10 - Spell cost - Sound magnitude) * (Current fatigue + Maximum Fatigue * 1.5) / Maximum fatigue * 2 /** - * @param spellId ID of spell + * @param spell spell to cast * @param actor calculate spell success chance for this actor (depends on actor's skills) * @attention actor has to be an NPC and not a creature! * @return success chance from 0 to 100 (in percent) */ - inline float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor) + inline float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - if (spell->mData.mFlags & ESM::Spell::F_Always // spells with this flag always succeed (usually birthsign spells) || spell->mData.mType == ESM::Spell::ST_Power) // powers always succeed, but can be cast only once per day return 100.0; + if (spell->mEffects.mList.size() == 0) + return 0.0; + NpcStats& stats = MWWorld::Class::get(actor).getNpcStats(actor); CreatureStats& creatureStats = MWWorld::Class::get(actor).getCreatureStats(actor); - int skillLevel = stats.getSkill (getSpellSchool(spellId, actor)).getModified(); + int skillLevel = stats.getSkill (getSpellSchool(spell, actor)).getModified(); // Sound magic effect (reduces spell casting chance) int soundMagnitude = creatureStats.getMagicEffects().get (MWMechanics::EffectKey (48)).mMagnitude; @@ -98,6 +104,12 @@ namespace MWMechanics return chance; } + + inline float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor) + { + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + return getSpellSuccessChance(spell, actor); + } } #endif diff --git a/files/mygui/openmw_spellcreation_dialog.layout b/files/mygui/openmw_spellcreation_dialog.layout index 4992243620..78d3f3de73 100644 --- a/files/mygui/openmw_spellcreation_dialog.layout +++ b/files/mygui/openmw_spellcreation_dialog.layout @@ -22,7 +22,6 @@ <Property key="Caption" value="#{sEnchantmentMenu4}"/> </Widget> <Widget type="TextBox" skin="SandText" position="280 0 258 24" name="MagickaCost"> - <Property key="Caption" value="1"/> <Property key="TextAlign" value="Right HCenter"/> </Widget> @@ -31,7 +30,6 @@ <Property key="Caption" value="#{sSpellmakingMenu1}"/> </Widget> <Widget type="TextBox" skin="SandText" position="280 24 258 24" name="SuccessChance"> - <Property key="Caption" value="39"/> <Property key="TextAlign" value="Right HCenter"/> </Widget> @@ -64,7 +62,6 @@ <Property key="Caption" value="#{sBarterDialog7}"/> </Widget> <Widget type="AutoSizedTextBox" skin="SandText" name="PriceLabel"> - <Property key="Caption" value="30"/> </Widget> From 9172c3ec4d840b9b3960ef3cae03e14fe90b8dff Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 23 Oct 2012 13:54:36 +0200 Subject: [PATCH 070/255] Issue #68: stop NPCs from instantly dropping dead --- apps/openmw/mwclass/npc.cpp | 7 +++++++ apps/openmw/mwmechanics/actors.cpp | 2 +- apps/openmw/mwmechanics/creaturestats.cpp | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 7e7e4937bf..bcde31b265 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -98,6 +98,13 @@ namespace MWClass else { /// \todo do something with mNpdt12 maybe:p + for (int i=0; i<8; ++i) + data->mCreatureStats.getAttribute (i).set (10); + + for (int i=0; i<3; ++i) + data->mCreatureStats.setDynamic (i, 10); + + data->mCreatureStats.setLevel (1); } data->mCreatureStats.setHello(ref->base->mAiData.mHello); diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index a33ef7240c..e8b6fc14d8 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -24,8 +24,8 @@ namespace MWMechanics { // magic effects adjustMagicEffects (ptr); - calculateCreatureStatModifiers (ptr); calculateDynamicStats (ptr); + calculateCreatureStatModifiers (ptr); // AI CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 1ce7bdb93a..8be4b93693 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -173,9 +173,9 @@ namespace MWMechanics { if (index < 0 || index > 2) throw std::runtime_error("dynamic stat index is out of range"); - + mDynamic[index] = value; - + if (index==2 && mDynamic[index].getCurrent()<1) mDead = true; } From 4ca0eb93eec7ef18f453ac8d086911bcc34f8a04 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 24 Oct 2012 17:47:03 +0200 Subject: [PATCH 071/255] fix markers used for raycasting and blocking activation --- components/nifbullet/bullet_nif_loader.cpp | 7 ++++--- libs/openengine/bullet/BulletShapeLoader.cpp | 3 ++- libs/openengine/bullet/BulletShapeLoader.h | 4 +++- libs/openengine/bullet/physic.cpp | 10 +++++++--- libs/openengine/bullet/physic.hpp | 3 ++- 5 files changed, 18 insertions(+), 9 deletions(-) diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index 6449ad246c..d2ec7ca825 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -71,7 +71,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { cShape = static_cast<BulletShape *>(resource); resourceName = cShape->getName(); - cShape->collide = false; + cShape->mCollide = false; mBoundingBox = NULL; cShape->boxTranslation = Ogre::Vector3(0,0,0); cShape->boxRotation = Ogre::Quaternion::IDENTITY; @@ -108,7 +108,7 @@ void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) handleNode(node,0,NULL,hasCollisionNode,false,false); //if collide = false, then it does a second pass which create a shape for raycasting. - if(cShape->collide == false) + if(cShape->mCollide == false) { handleNode(node,0,NULL,hasCollisionNode,false,true); } @@ -177,6 +177,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, if (node->name.find("marker") != std::string::npos) { flags |= 0x800; + cShape->mIgnore = true; } // Check for extra data @@ -254,7 +255,7 @@ void ManualBulletShapeLoader::handleNode(Nif::Node *node, int flags, } else if (node->recType == Nif::RC_NiTriShape && (isCollisionNode || !hasCollisionNode)) { - cShape->collide = !(flags&0x800); + cShape->mCollide = !(flags&0x800); handleNiTriShape(dynamic_cast<Nif::NiTriShape*>(node), flags,node->trafo.rotation,node->trafo.pos,node->trafo.scale,raycastingOnly); } else if(node->recType == Nif::RC_RootCollisionNode) diff --git a/libs/openengine/bullet/BulletShapeLoader.cpp b/libs/openengine/bullet/BulletShapeLoader.cpp index 59a414f301..dd3bca692c 100644 --- a/libs/openengine/bullet/BulletShapeLoader.cpp +++ b/libs/openengine/bullet/BulletShapeLoader.cpp @@ -16,7 +16,8 @@ Ogre::Resource(creator, name, handle, group, isManual, loader) we have none as such. Full details can be set through scripts. */ Shape = NULL; - collide = true; + mCollide = true; + mIgnore = false; createParamDictionary("BulletShape"); } diff --git a/libs/openengine/bullet/BulletShapeLoader.h b/libs/openengine/bullet/BulletShapeLoader.h index 8640fd54f0..21d21777a2 100644 --- a/libs/openengine/bullet/BulletShapeLoader.h +++ b/libs/openengine/bullet/BulletShapeLoader.h @@ -34,7 +34,9 @@ public: Ogre::Vector3 boxTranslation; Ogre::Quaternion boxRotation; //this flag indicate if the shape is used for collision or if it's for raycasting only. - bool collide; + bool mCollide; + + bool mIgnore; }; /** diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index 4f16a41438..d78e25ce7f 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -169,6 +169,7 @@ namespace Physic RigidBody::RigidBody(btRigidBody::btRigidBodyConstructionInfo& CI,std::string name) : btRigidBody(CI) , mName(name) + , mIgnore(false) { } @@ -327,7 +328,7 @@ namespace Physic btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,newMotionState,hfShape); RigidBody* body = new RigidBody(CI,name); - body->collide = true; + body->mCollide = true; body->getWorldTransform().setOrigin(btVector3( (x+0.5)*triSize*(sqrtVerts-1), (y+0.5)*triSize*(sqrtVerts-1), (maxh+minh)/2.f)); HeightField hf; @@ -397,7 +398,8 @@ namespace Physic //create the real body btRigidBody::btRigidBodyConstructionInfo CI = btRigidBody::btRigidBodyConstructionInfo(0,newMotionState,shape->Shape); RigidBody* body = new RigidBody(CI,name); - body->collide = shape->collide; + body->mCollide = shape->mCollide; + body->mIgnore = shape->mIgnore; if(scaledBoxTranslation != 0) *scaledBoxTranslation = shape->boxTranslation * scale; @@ -414,7 +416,9 @@ namespace Physic { if(body) { - if(body->collide) + if (body->mIgnore) + return; + if(body->mCollide) { dynamicsWorld->addRigidBody(body,COL_WORLD,COL_WORLD|COL_ACTOR_INTERNAL|COL_ACTOR_EXTERNAL); } diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index e4e71706f7..f320d009d9 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -152,7 +152,8 @@ namespace Physic std::string mName; //is this body used for raycasting only? - bool collide; + bool mCollide; + bool mIgnore; }; struct HeightField From 0ab432b074243f157520a80fd79e7df5ede9acde Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 25 Oct 2012 12:22:48 +0200 Subject: [PATCH 072/255] Issue #68: fixed death detection --- apps/openmw/mwmechanics/creaturestats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 8be4b93693..1e57ba3136 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -176,7 +176,7 @@ namespace MWMechanics mDynamic[index] = value; - if (index==2 && mDynamic[index].getCurrent()<1) + if (index==0 && mDynamic[index].getCurrent()<1) mDead = true; } From 21c24dedb63971c6c1d61b136ff4414964cd8b9f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 25 Oct 2012 12:28:45 +0200 Subject: [PATCH 073/255] Issue #68: Stop player from dying (temporary workaround) --- apps/openmw/mwmechanics/actors.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index e8b6fc14d8..0623db4b1c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -213,7 +213,27 @@ namespace MWMechanics } if (MWWorld::Class::get (*iter).getCreatureStats (*iter).isDead()) + { + // workaround: always keep player alive for now + // \todo remove workaround, once player death can be handled + if (iter->getRefData().getHandle()=="player") + { + MWMechanics::DynamicStat<float> stat ( + MWWorld::Class::get (*iter).getCreatureStats (*iter).getHealth()); + + if (stat.getModified()<1) + { + stat.setModified (1, 0); + MWWorld::Class::get (*iter).getCreatureStats (*iter).setHealth (stat); + } + + MWWorld::Class::get (*iter).getCreatureStats (*iter).resurrect(); + ++iter; + continue; + } + mActors.erase (iter++); + } else ++iter; } From 9f923e7963a00e13e6e288e1867f6f1089434d4f Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 25 Oct 2012 15:14:34 +0400 Subject: [PATCH 074/255] fix crashing if /home/greye/.cache not exist --- apps/openmw/mwrender/renderingmanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 21299e25c1..5b5fdce68e 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -67,7 +67,7 @@ RenderingManager::RenderingManager (OEngine::Render::OgreRenderer& _rend, const // material system sh::OgrePlatform* platform = new sh::OgrePlatform("General", (resDir / "materials").string()); if (!boost::filesystem::exists (cacheDir)) - boost::filesystem::create_directory (cacheDir); + boost::filesystem::create_directories (cacheDir); platform->setCacheFolder (cacheDir.string()); mFactory = new sh::Factory(platform); From 5d45d328b8e1d6359555dd95c757ac83d76d78b5 Mon Sep 17 00:00:00 2001 From: bwrsandman <mr.sandy.carter@gmail.com> Date: Fri, 26 Oct 2012 21:28:22 -0400 Subject: [PATCH 075/255] Fixed uninitialized variable that caused a segfault when going to previous page. --- apps/openmw/mwgui/journalwindow.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwgui/journalwindow.cpp b/apps/openmw/mwgui/journalwindow.cpp index 597c27c6df..9d5d236be0 100644 --- a/apps/openmw/mwgui/journalwindow.cpp +++ b/apps/openmw/mwgui/journalwindow.cpp @@ -85,6 +85,7 @@ MWGui::JournalWindow::JournalWindow (MWBase::WindowManager& parWindowManager) : WindowBase("openmw_journal.layout", parWindowManager) , mLastPos(0) , mVisible(false) + , mPageNumber(0) { //setCoord(0,0,498, 342); center(); From 6b09b3ad61ac9959c640fb70b0051264dce06739 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 27 Oct 2012 10:36:42 +0200 Subject: [PATCH 076/255] Issue #68: Play death animations --- apps/openmw/mwmechanics/actors.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 0623db4b1c..5c1560032c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -167,6 +167,8 @@ namespace MWMechanics { if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead()) mActors.insert (ptr); + else + MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, "death1", 2); } void Actors::removeActor (const MWWorld::Ptr& ptr) @@ -231,7 +233,9 @@ namespace MWMechanics ++iter; continue; } - + + MWBase::Environment::get().getWorld()->playAnimationGroup (*iter, "death1", 0); + mActors.erase (iter++); } else From f72c35fc172c5d66596fdac5588b8eebe2a5123e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 27 Oct 2012 11:15:52 +0200 Subject: [PATCH 077/255] Issue #68: tally deaths --- apps/openmw/mwmechanics/actors.cpp | 2 ++ apps/openmw/mwmechanics/actors.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 5c1560032c..0b1d0ba043 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -234,6 +234,8 @@ namespace MWMechanics continue; } + ++mDeathCount[MWWorld::Class::get (*iter).getId (*iter)]; + MWBase::Environment::get().getWorld()->playAnimationGroup (*iter, "death1", 0); mActors.erase (iter++); diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index f8a00f3492..fb6a42c472 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -4,6 +4,7 @@ #include <set> #include <vector> #include <string> +#include <map> namespace Ogre { @@ -22,6 +23,7 @@ namespace MWMechanics { std::set<MWWorld::Ptr> mActors; float mDuration; + std::map<std::string, int> mDeathCount; void updateNpc (const MWWorld::Ptr& ptr, float duration, bool paused); From 453f347ee8f0d801cc67dd9be63afa7574358fc7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 27 Oct 2012 11:33:18 +0200 Subject: [PATCH 078/255] Issue #68: added getdeadcount script function --- apps/openmw/mwbase/mechanicsmanager.hpp | 3 +++ apps/openmw/mwmechanics/actors.cpp | 10 ++++++++++ apps/openmw/mwmechanics/actors.hpp | 3 +++ apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 5 +++++ apps/openmw/mwmechanics/mechanicsmanagerimp.hpp | 4 ++++ apps/openmw/mwscript/docs/vmformat.txt | 3 ++- apps/openmw/mwscript/statsextensions.cpp | 17 +++++++++++++++++ 7 files changed, 44 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index c5d721e264..750fc2fff8 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -76,6 +76,9 @@ namespace MWBase virtual void restoreDynamicStats() = 0; ///< If the player is sleeping, this should be called every hour. + + virtual int countDeaths (const std::string& id) const = 0; + ///< Return the number of deaths for actors with the given ID. }; } diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 0b1d0ba043..1c9fefa16a 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -262,4 +262,14 @@ namespace MWMechanics calculateRestoration (*iter, 3600); } } + + int Actors::countDeaths (const std::string& id) const + { + std::map<std::string, int>::const_iterator iter = mDeathCount.find (id); + + if (iter!=mDeathCount.end()) + return iter->second; + + return 0; + } } diff --git a/apps/openmw/mwmechanics/actors.hpp b/apps/openmw/mwmechanics/actors.hpp index fb6a42c472..79ae16fc34 100644 --- a/apps/openmw/mwmechanics/actors.hpp +++ b/apps/openmw/mwmechanics/actors.hpp @@ -63,6 +63,9 @@ namespace MWMechanics void restoreDynamicStats(); ///< If the player is sleeping, this should be called every hour. + + int countDeaths (const std::string& id) const; + ///< Return the number of deaths for actors with the given ID. }; } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 6d8bdb3321..873dd94988 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -326,4 +326,9 @@ namespace MWMechanics buildPlayer(); mUpdatePlayer = true; } + + int MechanicsManager::countDeaths (const std::string& id) const + { + return mActors.countDeaths (id); + } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 205deaf714..38536d3bd7 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -78,6 +78,10 @@ namespace MWMechanics virtual void restoreDynamicStats(); ///< If the player is sleeping, this should be called every hour. + + virtual int countDeaths (const std::string& id) const; + ///< Return the number of deaths for actors with the given ID. + }; } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 584a299267..cb984e257c 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -206,5 +206,6 @@ op 0x200019f: GetPcSleep op 0x20001a0: ShowMap op 0x20001a1: FillMap op 0x20001a2: WakeUpPc -opcodes 0x20001a3-0x3ffffff unused +op 0x20001a3: GetDeadCount +opcodes 0x20001a4-0x3ffffff unused diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index fc57bb6545..0d69608e1c 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -17,6 +17,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/dialoguemanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" @@ -591,6 +592,17 @@ namespace MWScript /// \todo modify disposition towards the player } }; + + class OpGetDeadCount : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + std::string id = runtime.getStringLiteral (runtime[0].mInteger); + runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths (id); + } + }; const int numberOfAttributes = 8; @@ -643,6 +655,8 @@ namespace MWScript const int opcodeGetLevelExplicit = 0x200018d; const int opcodeSetLevel = 0x200018e; const int opcodeSetLevelExplicit = 0x200018f; + + const int opcodeGetDeadCount = 0x20001a3; void registerExtensions (Compiler::Extensions& extensions) { @@ -729,6 +743,8 @@ namespace MWScript extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit); extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit); + + extensions.registerFunction("getdeadcount", 'l', "c", opcodeGetDeadCount); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -806,6 +822,7 @@ namespace MWScript interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel<ImplicitRef>); interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>); + interpreter.installSegment5 (opcodeGetDeadCount, new OpGetDeadCount); } } } From ed3641b21445f26de214cd2ea7a64d50d98b9ddc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 27 Oct 2012 13:33:54 +0200 Subject: [PATCH 079/255] Issue #68: check for essential actors --- apps/openmw/mwclass/creature.cpp | 8 ++++++++ apps/openmw/mwclass/creature.hpp | 3 +++ apps/openmw/mwclass/npc.cpp | 8 ++++++++ apps/openmw/mwclass/npc.hpp | 3 +++ apps/openmw/mwmechanics/actors.cpp | 4 ++++ apps/openmw/mwworld/class.cpp | 5 +++++ apps/openmw/mwworld/class.hpp | 5 +++++ 7 files changed, 36 insertions(+) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 0fb9daf195..e007c50ab3 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -149,6 +149,14 @@ namespace MWClass return ref->base->mScript; } + bool Creature::isEssential (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef<ESM::Creature> *ref = + ptr.get<ESM::Creature>(); + + return ref->base->mFlags & ESM::Creature::Essential; + } + void Creature::registerSelf() { boost::shared_ptr<Class> instance (new Creature); diff --git a/apps/openmw/mwclass/creature.hpp b/apps/openmw/mwclass/creature.hpp index 4de877b31d..a158fa743e 100644 --- a/apps/openmw/mwclass/creature.hpp +++ b/apps/openmw/mwclass/creature.hpp @@ -56,6 +56,9 @@ namespace MWClass ///< Returns total weight of objects inside this object (including modifications from magic /// effects). Throws an exception, if the object can't hold other objects. + virtual bool isEssential (const MWWorld::Ptr& ptr) const; + ///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable) + static void registerSelf(); virtual std::string getModel(const MWWorld::Ptr &ptr) const; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index bcde31b265..ef3946efef 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -315,7 +315,15 @@ namespace MWClass return vector; } + + bool Npc::isEssential (const MWWorld::Ptr& ptr) const + { + MWWorld::LiveCellRef<ESM::NPC> *ref = + ptr.get<ESM::NPC>(); + return ref->base->mFlags & ESM::NPC::Essential; + } + void Npc::registerSelf() { boost::shared_ptr<Class> instance (new Npc); diff --git a/apps/openmw/mwclass/npc.hpp b/apps/openmw/mwclass/npc.hpp index edb6ca40fa..20c2da4b14 100644 --- a/apps/openmw/mwclass/npc.hpp +++ b/apps/openmw/mwclass/npc.hpp @@ -90,6 +90,9 @@ namespace MWClass virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const; + virtual bool isEssential (const MWWorld::Ptr& ptr) const; + ///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable) + static void registerSelf(); virtual std::string getModel(const MWWorld::Ptr &ptr) const; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 1c9fefa16a..f3b6b16162 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -238,6 +238,10 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->playAnimationGroup (*iter, "death1", 0); + if (MWWorld::Class::get (*iter).isEssential (*iter)) + MWBase::Environment::get().getWindowManager()->messageBox ( + "#{sKilledEssential}", std::vector<std::string>()); + mActors.erase (iter++); } else diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 5267e368dd..8c639a874c 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -157,6 +157,11 @@ namespace MWWorld throw std::runtime_error ("encumbrance not supported by class"); } + bool Class::isEssential (const MWWorld::Ptr& ptr) const + { + return false; + } + const Class& Class::get (const std::string& key) { std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 3c3b0e34be..4662cbab63 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -186,6 +186,11 @@ namespace MWWorld /// /// (default implementations: throws an exception) + virtual bool isEssential (const MWWorld::Ptr& ptr) const; + ///< Is \a ptr essential? (i.e. may losing \a ptr make the game unwinnable) + /// + /// (default implementation: return false) + static const Class& get (const std::string& key); ///< If there is no class for this \a key, an exception is thrown. From d7add0b9e679c1a7db6c2df0a288fc2bdafac083 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sun, 28 Oct 2012 14:07:36 +0100 Subject: [PATCH 080/255] Issue #61: fixed alchemy skill --- apps/openmw/mwmechanics/alchemy.cpp | 62 +++++++---------------------- apps/openmw/mwmechanics/alchemy.hpp | 5 +-- 2 files changed, 15 insertions(+), 52 deletions(-) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index df7c786b1e..962350472e 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -6,6 +6,7 @@ #include <algorithm> #include <stdexcept> +#include <map> #include <components/esm/loadskil.hpp> #include <components/esm/loadappa.hpp> @@ -28,7 +29,7 @@ std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const { - std::set<EffectKey> effects; + std::map<EffectKey, int> effects; for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter) { @@ -38,57 +39,23 @@ std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const for (int i=0; i<4; ++i) if (ingredient->base->mData.mEffectID[i]!=-1) - effects.insert (EffectKey ( + { + EffectKey key ( ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ? - ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i])); + ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i]); + + ++effects[key]; + } } } - return effects; -} - -void MWMechanics::Alchemy::filterEffects (std::set<EffectKey>& effects) const -{ - std::set<EffectKey>::iterator iter = effects.begin(); + std::set<EffectKey> effects2; - while (iter!=effects.end()) - { - bool remove = false; - - const EffectKey& key = *iter; - - { // dodge pointless g++ warning - for (TIngredientsIterator iter (mIngredients.begin()); iter!=mIngredients.end(); ++iter) - { - bool found = false; - - if (iter->isEmpty()) - continue; - - const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>(); - - for (int i=0; i<4; ++i) - if (key.mId==ingredient->base->mData.mEffectID[i] && - (key.mArg==ingredient->base->mData.mSkills[i] || - key.mArg==ingredient->base->mData.mAttributes[i])) - { - found = true; - break; - } - - if (!found) - { - remove = true; - break; - } - } - } - - if (remove) - effects.erase (iter++); - else - ++iter; - } + for (std::map<EffectKey, int>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter) + if (iter->second>1) + effects2.insert (iter->first); + + return effects2; } void MWMechanics::Alchemy::applyTools (int flags, float& value) const @@ -159,7 +126,6 @@ void MWMechanics::Alchemy::updateEffects() // find effects std::set<EffectKey> effects (listEffects()); - filterEffects (effects); // general alchemy factor float x = getChance(); diff --git a/apps/openmw/mwmechanics/alchemy.hpp b/apps/openmw/mwmechanics/alchemy.hpp index 7f3e2c0eaa..957e3122c7 100644 --- a/apps/openmw/mwmechanics/alchemy.hpp +++ b/apps/openmw/mwmechanics/alchemy.hpp @@ -46,10 +46,7 @@ namespace MWMechanics int mValue; std::set<EffectKey> listEffects() const; - ///< List all effects of all used ingredients. - - void filterEffects (std::set<EffectKey>& effects) const; - ///< Filter out effects not shared by all ingredients. + ///< List all effects shared by at least two ingredients. void applyTools (int flags, float& value) const; From a04df37f83097ac5b88a6fd98a43623eea2caa97 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sun, 28 Oct 2012 16:04:33 +0100 Subject: [PATCH 081/255] implemented looting corpses --- apps/openmw/mwclass/creature.cpp | 6 +++++- apps/openmw/mwclass/npc.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e007c50ab3..e4ff3c95ba 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -12,6 +12,7 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" +#include "../mwworld/actionopen.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -130,7 +131,10 @@ namespace MWClass boost::shared_ptr<MWWorld::Action> Creature::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { - return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); + if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead()) + return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr)); + else + return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); } MWWorld::ContainerStore& Creature::getContainerStore (const MWWorld::Ptr& ptr) diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index ef3946efef..2e21f8f63f 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -20,6 +20,7 @@ #include "../mwworld/ptr.hpp" #include "../mwworld/actiontalk.hpp" +#include "../mwworld/actionopen.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/physicssystem.hpp" @@ -189,7 +190,10 @@ namespace MWClass boost::shared_ptr<MWWorld::Action> Npc::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const { - return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); + if (MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead()) + return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionOpen(ptr)); + else + return boost::shared_ptr<MWWorld::Action> (new MWWorld::ActionTalk (ptr)); } MWWorld::ContainerStore& Npc::getContainerStore (const MWWorld::Ptr& ptr) From d065b56948954a2809b22e78d6515a8725cb827c Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 04:21:31 +0100 Subject: [PATCH 082/255] Fixed default profile adding and made switching profiles more efficient --- apps/launcher/datafilespage.cpp | 4 +++- apps/launcher/maindialog.cpp | 21 ++------------------- apps/launcher/maindialog.hpp | 1 - 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 01b8798426..696b378195 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -251,7 +251,7 @@ void DataFilesPage::setupConfig() } // Add a default profile - if (mProfilesComboBox->count() == 0) { + if (mProfilesComboBox->findText(QString("Default")) == -1) { mProfilesComboBox->addItem(QString("Default")); } @@ -359,6 +359,8 @@ bool DataFilesPage::setupDataFiles() ("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false)) ("encoding", boost::program_options::value<std::string>()->default_value("win1252")); + //boost::program_options::notify(variables); + mCfgMgr.readConfiguration(variables, desc); // Put the paths in a boost::filesystem vector to use with Files::Collections diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp index 3ce418ddf8..674ccdf672 100644 --- a/apps/launcher/maindialog.cpp +++ b/apps/launcher/maindialog.cpp @@ -141,11 +141,11 @@ void MainDialog::createPages() connect(mPlayPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(profileChanged(int))); + mDataFilesPage->mProfilesComboBox, SLOT(setCurrentIndex(int))); connect(mDataFilesPage->mProfilesComboBox, SIGNAL(currentIndexChanged(int)), - this, SLOT(profileChanged(int))); + mPlayPage->mProfilesComboBox, SLOT(setCurrentIndex(int))); } @@ -196,23 +196,6 @@ bool MainDialog::setup() return true; } -void MainDialog::profileChanged(int index) -{ - // Just to be sure, should always have a selection - if (!mIconWidget->selectionModel()->hasSelection()) { - return; - } - - QString currentPage = mIconWidget->currentItem()->data(Qt::DisplayRole).toString(); - if (currentPage == QLatin1String("Play")) { - mDataFilesPage->mProfilesComboBox->setCurrentIndex(index); - } - - if (currentPage == QLatin1String("Data Files")) { - mPlayPage->mProfilesComboBox->setCurrentIndex(index); - } -} - void MainDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) { if (!current) diff --git a/apps/launcher/maindialog.hpp b/apps/launcher/maindialog.hpp index 683cd58c26..bf98011cc4 100644 --- a/apps/launcher/maindialog.hpp +++ b/apps/launcher/maindialog.hpp @@ -27,7 +27,6 @@ public: public slots: void changePage(QListWidgetItem *current, QListWidgetItem *previous); void play(); - void profileChanged(int index); bool setup(); private: From ef11a32fee482b630def1e7282d3c170c9832080 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 05:03:58 +0100 Subject: [PATCH 083/255] Fixed a bug where a non-existant openmw.cfg would crash the launcher --- apps/launcher/datafilespage.cpp | 87 +++++++++++++++++++-------------- apps/launcher/datafilespage.hpp | 1 + 2 files changed, 51 insertions(+), 37 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 696b378195..50502f6e28 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -347,6 +347,47 @@ void DataFilesPage::readConfig() } +bool DataFilesPage::showDataFilesWarning() +{ + + QMessageBox msgBox; + msgBox.setWindowTitle("Error detecting Morrowind installation"); + msgBox.setIcon(QMessageBox::Warning); + msgBox.setStandardButtons(QMessageBox::Cancel); + msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \ + The directory containing the data files was not found.<br><br> \ + Press \"Browse...\" to specify the location manually.<br>")); + + QAbstractButton *dirSelectButton = + msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole); + + msgBox.exec(); + + if (msgBox.clickedButton() == dirSelectButton) { + + // Show a custom dir selection dialog which only accepts valid dirs + QString selectedDir = FileDialog::getExistingDirectory( + this, tr("Select Data Files Directory"), + QDir::currentPath(), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + // Add the user selected data directory + if (!selectedDir.isEmpty()) { + mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString())); + mCfgMgr.processPaths(mDataDirs); + } else { + // Cancel from within the dir selection dialog + return false; + } + + } else { + // Cancel + return false; + } + + return true; +} + bool DataFilesPage::setupDataFiles() { // We use the Configuration Manager to retrieve the configuration values @@ -359,12 +400,16 @@ bool DataFilesPage::setupDataFiles() ("fs-strict", boost::program_options::value<bool>()->implicit_value(true)->default_value(false)) ("encoding", boost::program_options::value<std::string>()->default_value("win1252")); - //boost::program_options::notify(variables); + boost::program_options::notify(variables); mCfgMgr.readConfiguration(variables, desc); - // Put the paths in a boost::filesystem vector to use with Files::Collections - mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>()); + if (variables["data"].empty()) { + if (!showDataFilesWarning()) + return false; + } else { + mDataDirs = Files::PathContainer(variables["data"].as<Files::PathContainer>()); + } std::string local = variables["data-local"].as<std::string>(); if (!local.empty()) { @@ -374,43 +419,11 @@ bool DataFilesPage::setupDataFiles() mCfgMgr.processPaths(mDataDirs); mCfgMgr.processPaths(mDataLocal); + // Second chance to display the warning, the data= entries are invalid while (mDataDirs.empty()) { - QMessageBox msgBox; - msgBox.setWindowTitle("Error detecting Morrowind installation"); - msgBox.setIcon(QMessageBox::Warning); - msgBox.setStandardButtons(QMessageBox::Cancel); - msgBox.setText(tr("<br><b>Could not find the Data Files location</b><br><br> \ - The directory containing the data files was not found.<br><br> \ - Press \"Browse...\" to specify the location manually.<br>")); - - QAbstractButton *dirSelectButton = - msgBox.addButton(tr("B&rowse..."), QMessageBox::ActionRole); - - msgBox.exec(); - - if (msgBox.clickedButton() == dirSelectButton) { - - // Show a custom dir selection dialog which only accepts valid dirs - QString selectedDir = FileDialog::getExistingDirectory( - this, tr("Select Data Files Directory"), - QDir::currentPath(), - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); - - // Add the user selected data directory - if (!selectedDir.isEmpty()) { - mDataDirs.push_back(Files::PathContainer::value_type(selectedDir.toStdString())); - mCfgMgr.processPaths(mDataDirs); - } else { - // Cancel from within the dir selection dialog - return false; - } - - } else { - // Cancel + if (!showDataFilesWarning()) return false; - } } - // Add the paths to the respective models for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { QString path = QString::fromStdString(it->string()); diff --git a/apps/launcher/datafilespage.hpp b/apps/launcher/datafilespage.hpp index 8b48c1e123..13668ec30e 100644 --- a/apps/launcher/datafilespage.hpp +++ b/apps/launcher/datafilespage.hpp @@ -30,6 +30,7 @@ public: ProfilesComboBox *mProfilesComboBox; void writeConfig(QString profile = QString()); + bool showDataFilesWarning(); bool setupDataFiles(); public slots: From 1c06a06f91b6e9ae41e9dd316663aae4eb426b98 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 06:47:39 +0100 Subject: [PATCH 084/255] Files are now sorted by modified timestamp, fixes Bug #415 --- apps/launcher/datafilespage.cpp | 11 +++-- apps/launcher/model/datafilesmodel.cpp | 57 +++++++++++++++++--------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 50502f6e28..782c4fb011 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -424,6 +424,7 @@ bool DataFilesPage::setupDataFiles() if (!showDataFilesWarning()) return false; } + // Add the paths to the respective models for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { QString path = QString::fromStdString(it->string()); @@ -440,8 +441,10 @@ bool DataFilesPage::setupDataFiles() mPluginsModel->addPlugins(path); } -// mMastersModel->sort(0); -// mPluginsModel->sort(0); + mMastersModel->sort(0); + mPluginsModel->sort(0); +// mMastersTable->sortByColumn(3, Qt::AscendingOrder); +// mPluginsTable->sortByColumn(3, Qt::AscendingOrder); readConfig(); @@ -734,8 +737,8 @@ void DataFilesPage::setCheckState(QModelIndex index) QModelIndex sourceIndex = mPluginsProxyModel->mapToSource(index); (mPluginsModel->checkState(sourceIndex) == Qt::Checked) - ? mPluginsModel->setCheckState(index, Qt::Unchecked) - : mPluginsModel->setCheckState(index, Qt::Checked); + ? mPluginsModel->setCheckState(sourceIndex, Qt::Unchecked) + : mPluginsModel->setCheckState(sourceIndex, Qt::Checked); } if (object->objectName() == QLatin1String("MastersTable")) { diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 0aa29a337a..d4674b9539 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -96,15 +96,11 @@ QVariant DataFilesModel::data(const QModelIndex &index, int role) const case Qt::TextAlignmentRole: { switch (column) { case 0: - return Qt::AlignLeft + Qt::AlignVCenter; case 1: return Qt::AlignLeft + Qt::AlignVCenter; case 2: - return Qt::AlignRight + Qt::AlignVCenter; case 3: - return Qt::AlignRight + Qt::AlignVCenter; case 4: - return Qt::AlignRight + Qt::AlignVCenter; case 5: return Qt::AlignRight + Qt::AlignVCenter; default: @@ -218,20 +214,34 @@ void DataFilesModel::sort(int column, Qt::SortOrder order) // TODO: Make this more efficient emit layoutAboutToBeChanged(); - // A reference list we can sort - QStringList all = uncheckedItems(); - //all.append(uncheckedItems()); - // Sort the list of items naturally - qSort(all.begin(), all.end(), naturalSortLessThanCI); + QMap<QString, QString> timestamps; - for (int i = 0; i < all.size(); ++i) { - const QString currentItem = all.at(i); - QModelIndex index = indexFromItem(findItem(currentItem)); + QList<EsmFile *>::ConstIterator it; + QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); - // Move the actual item from the old position to the new - if (index.isValid()) + // Make a list of files sorted by timestamp + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + timestamps[file->modified().toString(Qt::ISODate)] = file->fileName(); + } + + + // Now sort the actual list of files by timestamp + i = 0; + QMapIterator<QString, QString> ti(timestamps); + while (ti.hasNext()) { + ti.next(); + i++; + + QModelIndex index = indexFromItem(findItem(ti.value())); + + if (index.isValid()) { mFiles.swap(index.row(), i); + } + } emit layoutChanged(); @@ -381,13 +391,20 @@ EsmFile* DataFilesModel::item(int row) QStringList DataFilesModel::checkedItems() { QStringList list; - QHash<QString, Qt::CheckState>::ConstIterator it; - QHash<QString, Qt::CheckState>::ConstIterator itEnd = mCheckStates.constEnd(); - for (it = mCheckStates.constBegin(); it != itEnd; ++it) { - if (it.value() == Qt::Checked) { - list << it.key(); - } + QList<EsmFile *>::ConstIterator it; + QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); + + int i = 0; + for (it = mFiles.constBegin(); it != itEnd; ++it) { + EsmFile *file = item(i); + ++i; + + QString name = file->fileName(); + + // Only add the items that are in the checked list and available + if (mCheckStates[name] == Qt::Checked && mAvailableFiles.contains(name)) + list << name; } return list; From 6e758af05c4898634a4f97dd1b2e41848800947a Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 06:51:22 +0100 Subject: [PATCH 085/255] Launcher cfg is stored in the user location only, fixes Bug #414 --- apps/launcher/datafilespage.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 782c4fb011..32bd9acb78 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -220,16 +220,9 @@ void DataFilesPage::createActions() void DataFilesPage::setupConfig() { - QString config = QString::fromStdString((mCfgMgr.getLocalPath() / "launcher.cfg").string()); - QFile file(config); - - if (!file.exists()) { - config = QString::fromStdString((mCfgMgr.getUserPath() / "launcher.cfg").string()); - } - // Open our config file + QString config = QString::fromStdString((mCfgMgr.getUserPath() / "launcher.cfg").string()); mLauncherConfig = new QSettings(config, QSettings::IniFormat); - file.close(); // Make sure we have no groups open while (!mLauncherConfig->group().isEmpty()) { From 6920958e160149705c2c407839adba6e713d72ea Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 10:08:24 +0100 Subject: [PATCH 086/255] Oops, forgot to add timestamps for master files --- apps/launcher/model/datafilesmodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index d4674b9539..40dd78fce4 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -281,6 +281,7 @@ void DataFilesModel::addMasters(const QString &path) continue; EsmFile *file = new EsmFile(master); + file->setDates(info.lastModified(), info.lastRead()); // Add the master to the table if (findItem(master) == 0) @@ -299,9 +300,12 @@ void DataFilesModel::addMasters(const QString &path) dir.setNameFilters(QStringList(QLatin1String("*.esm"))); foreach (const QString &path, dir.entryList()) { + QFileInfo info(dir.absoluteFilePath(path)); if (findItem(path) == 0) { EsmFile *file = new EsmFile(path); + file->setDates(info.lastModified(), info.lastRead()); + addFile(file); } From 433773e0eadb28823fff44151ba5059b1ab56c81 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 11:10:06 +0100 Subject: [PATCH 087/255] Fixed segfault in datafilesmodel because of invalid modelindex row --- apps/launcher/model/datafilesmodel.cpp | 13 ++++++++----- apps/launcher/model/datafilesmodel.hpp | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 40dd78fce4..30453425b2 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -60,10 +60,10 @@ QVariant DataFilesModel::data(const QModelIndex &index, int role) const if (!index.isValid()) return QVariant(); -// if (index.row() < 0 || index.row() >= mPlugins.size()) -// return QVariant(); + EsmFile *file = item(index.row()); - EsmFile *file = mFiles.at(index.row()); + if (!file) + return QVariant(); const int column = index.column(); @@ -146,7 +146,10 @@ Qt::ItemFlags DataFilesModel::flags(const QModelIndex &index) const if (!index.isValid()) return Qt::NoItemFlags; - EsmFile *file = mFiles.at(index.row()); + EsmFile *file = item(index.row()); + + if (!file) + return Qt::NoItemFlags; if (mAvailableFiles.contains(file->fileName())) { if (index.column() == 0) { @@ -384,7 +387,7 @@ EsmFile* DataFilesModel::findItem(const QString &name) return 0; } -EsmFile* DataFilesModel::item(int row) +EsmFile* DataFilesModel::item(int row) const { if (row >= 0 && row < mFiles.count()) return mFiles.at(row); diff --git a/apps/launcher/model/datafilesmodel.hpp b/apps/launcher/model/datafilesmodel.hpp index 8710ba88d3..d45788c3cb 100644 --- a/apps/launcher/model/datafilesmodel.hpp +++ b/apps/launcher/model/datafilesmodel.hpp @@ -47,7 +47,7 @@ public: QModelIndex indexFromItem(EsmFile *item) const; EsmFile* findItem(const QString &name); - EsmFile* item(int row); + EsmFile* item(int row) const; signals: void checkedItemsChanged(const QStringList checkedItems, const QStringList unCheckedItems); From 64c348c39ed6cc6fe5de0e042d7b1fb53c14cf25 Mon Sep 17 00:00:00 2001 From: Pieter van der Kloet <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 11:26:48 +0100 Subject: [PATCH 088/255] Added support for different encodings --- apps/launcher/datafilespage.cpp | 7 +++++++ apps/launcher/model/datafilesmodel.cpp | 10 ++++++++-- apps/launcher/model/datafilesmodel.hpp | 4 ++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/apps/launcher/datafilespage.cpp b/apps/launcher/datafilespage.cpp index 32bd9acb78..6b0539c1dd 100644 --- a/apps/launcher/datafilespage.cpp +++ b/apps/launcher/datafilespage.cpp @@ -418,6 +418,13 @@ bool DataFilesPage::setupDataFiles() return false; } + // Set the charset for reading the esm/esp files + QString encoding = QString::fromStdString(variables["encoding"].as<std::string>()); + if (!encoding.isEmpty() && encoding != QLatin1String("win1252")) { + mMastersModel->setEncoding(encoding); + mPluginsModel->setEncoding(encoding); + } + // Add the paths to the respective models for (Files::PathContainer::iterator it = mDataDirs.begin(); it != mDataDirs.end(); ++it) { QString path = QString::fromStdString(it->string()); diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 30453425b2..68f9336f21 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -13,12 +13,18 @@ DataFilesModel::DataFilesModel(QObject *parent) : QAbstractTableModel(parent) { + mEncoding = QString("win1252"); } DataFilesModel::~DataFilesModel() { } +void DataFilesModel::setEncoding(const QString &encoding) +{ + mEncoding = encoding; +} + void DataFilesModel::setCheckState(const QModelIndex &index, Qt::CheckState state) { setData(index, state, Qt::CheckStateRole); @@ -268,7 +274,7 @@ void DataFilesModel::addMasters(const QString &path) try { ESM::ESMReader fileReader; - fileReader.setEncoding(std::string("win1252")); + fileReader.setEncoding(mEncoding.toStdString()); fileReader.open(dir.absoluteFilePath(path).toStdString()); ESM::ESMReader::MasterList mlist = fileReader.getMasters(); @@ -328,7 +334,7 @@ void DataFilesModel::addPlugins(const QString &path) try { ESM::ESMReader fileReader; - fileReader.setEncoding(std::string("win1252")); + fileReader.setEncoding(mEncoding.toStdString()); fileReader.open(dir.absoluteFilePath(path).toStdString()); ESM::ESMReader::MasterList mlist = fileReader.getMasters(); diff --git a/apps/launcher/model/datafilesmodel.hpp b/apps/launcher/model/datafilesmodel.hpp index d45788c3cb..29a770a862 100644 --- a/apps/launcher/model/datafilesmodel.hpp +++ b/apps/launcher/model/datafilesmodel.hpp @@ -32,6 +32,8 @@ public: inline QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const { return QAbstractTableModel::index(row, column, parent); } + void setEncoding(const QString &encoding); + void addFile(EsmFile *file); void addMasters(const QString &path); @@ -62,6 +64,8 @@ private: QHash<QString, QStringList> mDependencies; QHash<QString, Qt::CheckState> mCheckStates; + QString mEncoding; + }; #endif // DATAFILESMODEL_HPP From 60aea3653fcf0703a9fc8ba2625295d0b8e24fca Mon Sep 17 00:00:00 2001 From: pvdk <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 18:58:17 +0100 Subject: [PATCH 089/255] Modified sorting, should not crash anymore --- apps/launcher/model/datafilesmodel.cpp | 36 +++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 68f9336f21..70b9d0ca75 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -223,36 +223,34 @@ void DataFilesModel::sort(int column, Qt::SortOrder order) // TODO: Make this more efficient emit layoutAboutToBeChanged(); + QList<EsmFile *> sortedFiles; - QMap<QString, QString> timestamps; + QMultiMap<QString, QString> timestamps; - QList<EsmFile *>::ConstIterator it; - QList<EsmFile *>::ConstIterator itEnd = mFiles.constEnd(); + foreach (EsmFile *file, mFiles) + timestamps.insert(file->modified().toString(Qt::ISODate), file->fileName()); - // Make a list of files sorted by timestamp - int i = 0; - for (it = mFiles.constBegin(); it != itEnd; ++it) { - EsmFile *file = item(i); - ++i; - timestamps[file->modified().toString(Qt::ISODate)] = file->fileName(); - } - - - // Now sort the actual list of files by timestamp - i = 0; QMapIterator<QString, QString> ti(timestamps); + while (ti.hasNext()) { ti.next(); - i++; QModelIndex index = indexFromItem(findItem(ti.value())); - if (index.isValid()) { - mFiles.swap(index.row(), i); - } + if (!index.isValid()) + continue; + EsmFile *file = item(index.row()); + + if (!file) + continue; + + sortedFiles.append(file); } + mFiles.clear(); + mFiles = sortedFiles; + emit layoutChanged(); } @@ -301,6 +299,7 @@ void DataFilesModel::addMasters(const QString &path) } catch(std::runtime_error &e) { // An error occurred while reading the .esp + qWarning() << "Error reading esp: " << e.what(); continue; } } @@ -361,6 +360,7 @@ void DataFilesModel::addPlugins(const QString &path) addFile(file); } catch(std::runtime_error &e) { // An error occurred while reading the .esp + qWarning() << "Error reading esp: " << e.what(); continue; } From b0647d6c8a8f4057594f1b2e6c61f51fa1badc9f Mon Sep 17 00:00:00 2001 From: pvdk <pvdkloet@gmail.com> Date: Tue, 30 Oct 2012 19:05:44 +0100 Subject: [PATCH 090/255] Fix for Bug #413: resolutions no longer appear multiple times on Windows --- apps/launcher/graphicspage.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/apps/launcher/graphicspage.cpp b/apps/launcher/graphicspage.cpp index 7685cb3c20..2c4f3430c5 100644 --- a/apps/launcher/graphicspage.cpp +++ b/apps/launcher/graphicspage.cpp @@ -281,20 +281,18 @@ QStringList GraphicsPage::getAvailableResolutions(Ogre::RenderSystem *renderer) assert (tokens.size() >= 3); QString resolutionStr = tokens.at(0) + QString(" x ") + tokens.at(2); - // do not add duplicate resolutions - if (!result.contains(resolutionStr)) { + QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt()); - QString aspect = getAspect(tokens.at(0).toInt(),tokens.at(2).toInt()); + if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { + resolutionStr.append(tr("\t(Widescreen ") + aspect + ")"); - if (aspect == QLatin1String("16:9") || aspect == QLatin1String("16:10")) { - resolutionStr.append(tr("\t(Widescreen ") + aspect + ")"); - - } else if (aspect == QLatin1String("4:3")) { - resolutionStr.append(tr("\t(Standard 4:3)")); - } - - result << resolutionStr; + } else if (aspect == QLatin1String("4:3")) { + resolutionStr.append(tr("\t(Standard 4:3)")); } + + // do not add duplicate resolutions + if (!result.contains(resolutionStr)) + result << resolutionStr; } } From 648b53ef9352477cbedc7ae36a512f1736ff52c7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Wed, 31 Oct 2012 10:09:27 +0100 Subject: [PATCH 091/255] removed unused launcher.cfg file --- CMakeLists.txt | 1 - apps/launcher/CMakeLists.txt | 5 ----- files/launcher.cfg | 5 ----- 3 files changed, 11 deletions(-) delete mode 100644 files/launcher.cfg diff --git a/CMakeLists.txt b/CMakeLists.txt index b10562eef2..a6fdfceb17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -659,7 +659,6 @@ if (NOT WIN32 AND NOT DPKG_PROGRAM AND NOT APPLE) #INSTALL(FILES "${OpenMW_BINARY_DIR}/plugins.cfg" DESTINATION "${SYSCONFDIR}" ) INSTALL(FILES "${OpenMW_BINARY_DIR}/settings-default.cfg" DESTINATION "${SYSCONFDIR}" ) INSTALL(FILES "${OpenMW_BINARY_DIR}/transparency-overrides.cfg" DESTINATION "${SYSCONFDIR}" ) - INSTALL(FILES "${OpenMW_BINARY_DIR}/launcher.cfg" DESTINATION "${SYSCONFDIR}" ) # Install resources INSTALL(DIRECTORY "${OpenMW_BINARY_DIR}/resources" DESTINATION "${DATADIR}" ) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index edc3dcf32e..09beaf59de 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -101,8 +101,6 @@ endif() if (APPLE) configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${APP_BUNDLE_DIR}/../launcher.qss") - configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg - "${APP_BUNDLE_DIR}/../launcher.cfg") else() configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/resources/launcher.qss") @@ -110,9 +108,6 @@ else() # Fallback in case getGlobalDataPath does not point to resources configure_file(${CMAKE_SOURCE_DIR}/files/launcher.qss "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.qss") - - configure_file(${CMAKE_SOURCE_DIR}/files/launcher.cfg - "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/launcher.cfg") endif() if (BUILD_WITH_CODE_COVERAGE) diff --git a/files/launcher.cfg b/files/launcher.cfg deleted file mode 100644 index bc0e2b7fb8..0000000000 --- a/files/launcher.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[Profiles] -CurrentProfile=Default -Default\Master0=Morrowind.esm -Default\Master1=Tribunal.esm -Default\Master2=Bloodmoon.esm From 4bc4ca775cfd36b6fdd97dbaa071dc79a3c947ec Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 1 Nov 2012 15:11:13 +0100 Subject: [PATCH 092/255] Issue #432: fixed MWWorld::ContainerStore::clear --- apps/openmw/mwworld/containerstore.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 3bc06b5813..5c4dd03a45 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -167,18 +167,8 @@ void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS: void MWWorld::ContainerStore::clear() { - potions.list.clear(); - appas.list.clear(); - armors.list.clear(); - books.list.clear(); - clothes.list.clear(); - ingreds.list.clear(); - lights.list.clear(); - lockpicks.list.clear(); - miscItems.list.clear(); - probes.list.clear(); - repairs.list.clear(); - weapons.list.clear(); + for (ContainerStoreIterator iter (begin()); iter!=end(); ++iter) + iter->getRefData().setCount (0); flagAsModified(); } From 37a42c7dbc1f700ee71a8abca41dea0717e7568d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 1 Nov 2012 16:38:07 +0100 Subject: [PATCH 093/255] increased version number; updated changelog --- CMakeLists.txt | 2 +- readme.txt | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a6fdfceb17..78388e20f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include (OpenMWMacros) # Version set (OPENMW_VERSION_MAJOR 0) -set (OPENMW_VERSION_MINOR 18) +set (OPENMW_VERSION_MINOR 19) set (OPENMW_VERSION_RELEASE 0) set (OPENMW_VERSION "${OPENMW_VERSION_MAJOR}.${OPENMW_VERSION_MINOR}.${OPENMW_VERSION_RELEASE}") diff --git a/readme.txt b/readme.txt index 20aff18aef..9a90109945 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ OpenMW: A reimplementation of The Elder Scrolls III: Morrowind OpenMW is an attempt at recreating the engine for the popular role-playing game Morrowind by Bethesda Softworks. You need to own and install the original game for OpenMW to work. -Version: 0.18.0 +Version: 0.19.0 License: GPL (see GPL3.txt for more information) Website: http://www.openmw.org @@ -97,6 +97,32 @@ Allowed options: CHANGELOG +0.19.0 + +Bug #374: Character shakes in 3rd person mode near the origin +Bug #404: Gamma correct rendering +Bug #407: Shoes of St. Rilm do not work +Bug #408: Rugs has collision even if they are not supposed to +Bug #412: Birthsign menu sorted incorrectly +Bug #413: Resolutions presented multiple times in launcher +Bug #414: launcher.cfg file stored in wrong directory +Bug #415: Wrong esm order in openmw.cfg +Bug #418: Sound listener position updates incorrectly +Bug #423: wrong usage of "Version" entry in openmw.desktop +Bug #426: Do not use hardcoded splash images +Bug #431: Don't use markers for raycast +Bug #432: Crash after picking up items from an NPC +Feature #21/#95: Sleeping/resting +Feature #61: Alchemy Skill +Feature #68: Death +Feature #69/#86: Spell Creation +Feature #72/#84: Travel +Feature #76: Global Map, 1st Layer +Feature #120: Trainer Window +Feature #152: Skill Increase from Skill Books +Feature #160: Record Saving +Task #400: Review GMST access + 0.18.0 Bug #310: Button of the "preferences menu" are too small From 8cdd1e553968b76d893ae3731b5e2c08f72ff295 Mon Sep 17 00:00:00 2001 From: pvdk <pvdkloet@gmail.com> Date: Fri, 2 Nov 2012 15:06:14 +0100 Subject: [PATCH 094/255] Fixed problem with sorting of the masters in the launcher --- apps/launcher/model/datafilesmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 70b9d0ca75..47811dcaf0 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -268,8 +268,6 @@ void DataFilesModel::addMasters(const QString &path) // Read the dependencies from the plugins foreach (const QString &path, dir.entryList()) { - QFileInfo info(dir.absoluteFilePath(path)); - try { ESM::ESMReader fileReader; fileReader.setEncoding(mEncoding.toStdString()); @@ -287,6 +285,8 @@ void DataFilesModel::addMasters(const QString &path) if (master.endsWith(".esp", Qt::CaseInsensitive)) continue; + QFileInfo info(dir.absoluteFilePath(master)); + EsmFile *file = new EsmFile(master); file->setDates(info.lastModified(), info.lastRead()); From 15f972cc6256b26044ac1af4fbbf947c0e8bc037 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Fri, 2 Nov 2012 20:33:08 +0000 Subject: [PATCH 095/255] fixes: compile: cast error; doors: key id case comparison; character creation: going from CharacterCreation to BirthDialog loses data; character creation: Class/Race/BirthDialog allowing no data; code: clean up a bit todo: going from CharacterCreation back to CreateClassDialog loses data --- apps/openmw/mwclass/door.cpp | 8 +++++- apps/openmw/mwgui/birth.cpp | 2 ++ apps/openmw/mwgui/charactercreation.cpp | 1 + apps/openmw/mwgui/class.cpp | 4 +++ apps/openmw/mwgui/race.cpp | 2 ++ apps/openmw/mwgui/stats_window.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 6 +---- apps/openmw/mwworld/scene.cpp | 33 +++++-------------------- 8 files changed, 24 insertions(+), 34 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index b94a24ed5c..4687a82304 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -81,9 +81,15 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef ().mRefID == ptr.getCellRef().mKey) + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + if (refId == keyId) { hasKey = true; keyName = MWWorld::Class::get(*it).getName(*it); diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 284653aee3..1cd5422216 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -93,6 +93,8 @@ void BirthDialog::setBirthId(const std::string &birthId) void BirthDialog::onOkClicked(MyGUI::Widget* _sender) { + if(mBirthList->getIndexSelected() == MyGUI::ITEM_NONE) + return; eventDone(this); } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index e5bcdbaf87..ad9866eca6 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -232,6 +232,7 @@ void CharacterCreation::spawnDialog(const char id) mBirthSignDialog = 0; mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); + mBirthSignDialog->setBirthId(mPlayerBirthSignId); mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->setVisible(true); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 8757b62a35..4c889d42d4 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -148,6 +148,8 @@ void PickClassDialog::setClassId(const std::string &classId) void PickClassDialog::onOkClicked(MyGUI::Widget* _sender) { + if(mClassList->getIndexSelected() == MyGUI::ITEM_NONE) + return; eventDone(this); } @@ -641,6 +643,8 @@ void CreateClassDialog::onDescriptionEntered(WindowBase* parWindow) void CreateClassDialog::onOkClicked(MyGUI::Widget* _sender) { + if(getName().size() <= 0) + return; eventDone(this); } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 019a59cf4c..c68c0edad7 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -149,6 +149,8 @@ void RaceDialog::close() void RaceDialog::onOkClicked(MyGUI::Widget* _sender) { + if(mRaceList->getIndexSelected() == MyGUI::ITEM_NONE) + return; eventDone(this); } diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 5a670968e0..665caaae1a 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -67,7 +67,7 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager) for (int i = 0; i < ESM::Skill::Length; ++i) { mSkillValues.insert(std::pair<int, MWMechanics::Stat<float> >(i, MWMechanics::Stat<float>())); - mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, nullptr)); + mSkillWidgetMap.insert(std::pair<int, MyGUI::TextBox*>(i, (MyGUI::TextBox*)nullptr)); } MyGUI::WindowPtr t = static_cast<MyGUI::WindowPtr>(mMainWidget); diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 8fa1976ac2..a2825fee99 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -345,11 +345,7 @@ namespace MWWorld bool PhysicsSystem::toggleCollisionMode() { - if(playerphysics->ps.move_type==PM_NOCLIP) - playerphysics->ps.move_type=PM_NORMAL; - - else - playerphysics->ps.move_type=PM_NOCLIP; + playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP); for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { if (it->first=="player") diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index f160772020..517025fb2f 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -70,17 +70,9 @@ namespace MWWorld { std::cout << "Unloading cell\n"; ListHandles functor; - - - - - - + (*iter)->forEach<ListHandles>(functor); - { - - // silence annoying g++ warning for (std::vector<Ogre::SceneNode*>::const_iterator iter2 (functor.mHandles.begin()); iter2!=functor.mHandles.end(); ++iter2){ @@ -96,27 +88,20 @@ namespace MWWorld } } - mRendering.removeCell(*iter); - //mPhysics->removeObject("Unnamed_43"); + mRendering.removeCell(*iter); + //mPhysics->removeObject("Unnamed_43"); MWBase::Environment::get().getWorld()->getLocalScripts().clearCell (*iter); MWBase::Environment::get().getMechanicsManager()->dropActors (*iter); MWBase::Environment::get().getSoundManager()->stopSound (*iter); - mActiveCells.erase(*iter); - - - + mActiveCells.erase(*iter); } void Scene::loadCell (Ptr::CellStore *cell) { // register local scripts MWBase::Environment::get().getWorld()->getLocalScripts().addCell (cell); - - - - std::pair<CellStoreCollection::iterator, bool> result = - mActiveCells.insert(cell); + std::pair<CellStoreCollection::iterator, bool> result = mActiveCells.insert(cell); if(result.second) { @@ -138,16 +123,10 @@ namespace MWWorld mRendering.configureAmbient(*cell); mRendering.requestMap(cell); mRendering.configureAmbient(*cell); - } - } - void - Scene::playerCellChange( - MWWorld::CellStore *cell, - const ESM::Position& pos, - bool adjustPlayerPos) + void Scene::playerCellChange(MWWorld::CellStore *cell, const ESM::Position& pos, bool adjustPlayerPos) { bool hasWater = cell->cell->mData.mFlags & cell->cell->HasWater; mPhysics->setCurrentWater(hasWater, cell->cell->mWater); From 4a9821dc652cd5e50dd76ed257d06a37bdfa6332 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Fri, 2 Nov 2012 20:43:07 +0000 Subject: [PATCH 096/255] fix kdevelop indentation... --- apps/openmw/mwclass/door.cpp | 12 ++++++------ apps/openmw/mwgui/birth.cpp | 2 +- apps/openmw/mwgui/charactercreation.cpp | 2 +- apps/openmw/mwgui/class.cpp | 2 +- apps/openmw/mwgui/race.cpp | 2 +- apps/openmw/mwworld/physicssystem.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 4687a82304..f944391e12 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -81,14 +81,14 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; - - // make key id lowercase - std::string keyId = ptr.getCellRef().mKey; - std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - std::string refId = it->getCellRef().mRefID; - std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); if (refId == keyId) { hasKey = true; diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 1cd5422216..e79eee2363 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -94,7 +94,7 @@ void BirthDialog::setBirthId(const std::string &birthId) void BirthDialog::onOkClicked(MyGUI::Widget* _sender) { if(mBirthList->getIndexSelected() == MyGUI::ITEM_NONE) - return; + return; eventDone(this); } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index ad9866eca6..e4b77287c3 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -232,7 +232,7 @@ void CharacterCreation::spawnDialog(const char id) mBirthSignDialog = 0; mBirthSignDialog = new BirthDialog(*mWM); mBirthSignDialog->setNextButtonShow(mCreationStage >= CSE_BirthSignChosen); - mBirthSignDialog->setBirthId(mPlayerBirthSignId); + mBirthSignDialog->setBirthId(mPlayerBirthSignId); mBirthSignDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogDone); mBirthSignDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onBirthSignDialogBack); mBirthSignDialog->setVisible(true); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 4c889d42d4..3e293a1b07 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -149,7 +149,7 @@ void PickClassDialog::setClassId(const std::string &classId) void PickClassDialog::onOkClicked(MyGUI::Widget* _sender) { if(mClassList->getIndexSelected() == MyGUI::ITEM_NONE) - return; + return; eventDone(this); } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index c68c0edad7..9abb053904 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -150,7 +150,7 @@ void RaceDialog::close() void RaceDialog::onOkClicked(MyGUI::Widget* _sender) { if(mRaceList->getIndexSelected() == MyGUI::ITEM_NONE) - return; + return; eventDone(this); } diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index a2825fee99..3be85c7f3d 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -345,7 +345,7 @@ namespace MWWorld bool PhysicsSystem::toggleCollisionMode() { - playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP); + playerphysics->ps.move_type = (playerphysics->ps.move_type == PM_NOCLIP ? PM_NORMAL : PM_NOCLIP); for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++) { if (it->first=="player") From 96b56d98032b7453cc8e25b4f9d4a15f4697fc1a Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Fri, 2 Nov 2012 21:18:37 +0000 Subject: [PATCH 097/255] fixes: containers: key id case comparison --- apps/openmw/mwclass/container.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 28fa723786..07f1c26ce7 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -95,9 +95,15 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - if (it->getCellRef ().mRefID == ptr.getCellRef().mKey) + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + if (refId == keyId) { hasKey = true; keyName = MWWorld::Class::get(*it).getName(*it); From 1c8e941f0d49a439273169130e08c5b3e7a33b83 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Fri, 2 Nov 2012 21:21:32 +0000 Subject: [PATCH 098/255] fix kdevelop indentation again... --- apps/openmw/mwclass/container.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 07f1c26ce7..237f451f33 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -95,14 +95,14 @@ namespace MWClass bool needKey = ptr.getCellRef().mLockLevel>0; bool hasKey = false; std::string keyName; - - // make key id lowercase - std::string keyId = ptr.getCellRef().mKey; - std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); + + // make key id lowercase + std::string keyId = ptr.getCellRef().mKey; + std::transform(keyId.begin(), keyId.end(), keyId.begin(), ::tolower); for (MWWorld::ContainerStoreIterator it = invStore.begin(); it != invStore.end(); ++it) { - std::string refId = it->getCellRef().mRefID; - std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); + std::string refId = it->getCellRef().mRefID; + std::transform(refId.begin(), refId.end(), refId.begin(), ::tolower); if (refId == keyId) { hasKey = true; From b70b8cc4bc32ad8867e716e61f28973d0dd50a99 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Sat, 3 Nov 2012 06:02:33 +0000 Subject: [PATCH 099/255] Fixed: character creation: make OK button grayed out/disabled (loses the hoverover when it's re-enabled though...) --- apps/openmw/mwgui/birth.cpp | 8 ++++++++ apps/openmw/mwgui/class.cpp | 8 ++++++++ apps/openmw/mwgui/race.cpp | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index e79eee2363..56e566ffbc 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -48,6 +48,7 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); + okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); updateBirths(); updateSpells(); @@ -82,6 +83,9 @@ void BirthDialog::setBirthId(const std::string &birthId) if (boost::iequals(*mBirthList->getItemDataAt<std::string>(i), birthId)) { mBirthList->setIndexSelected(i); + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); break; } } @@ -108,6 +112,10 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + const std::string *birthId = mBirthList->getItemDataAt<std::string>(_index); if (boost::iequals(mCurrentBirthId, *birthId)) return; diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 3e293a1b07..a798ca2323 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -104,6 +104,7 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); + okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); updateClasses(); updateStats(); @@ -137,6 +138,9 @@ void PickClassDialog::setClassId(const std::string &classId) if (boost::iequals(*mClassList->getItemDataAt<std::string>(i), classId)) { mClassList->setIndexSelected(i); + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); break; } } @@ -163,6 +167,10 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + const std::string *classId = mClassList->getItemDataAt<std::string>(_index); if (boost::iequals(mCurrentClassId, *classId)) return; diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 9abb053904..b1d51db09f 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -80,6 +80,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); + okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); updateRaces(); updateSkills(); @@ -121,6 +122,9 @@ void RaceDialog::setRaceId(const std::string &raceId) if (boost::iequals(*mRaceList->getItemDataAt<std::string>(i), raceId)) { mRaceList->setIndexSelected(i); + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); break; } } @@ -202,6 +206,9 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) if (_index == MyGUI::ITEM_NONE) return; + MyGUI::ButtonPtr okButton; + getWidget(okButton, "OKButton"); + okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); const std::string *raceId = mRaceList->getItemDataAt<std::string>(_index); if (boost::iequals(mCurrentRaceId, *raceId)) return; From c8cc6b6e65f04fff1b18d504c6f601dd8e66bb6e Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Sat, 3 Nov 2012 16:39:32 +0000 Subject: [PATCH 100/255] Fixed: engine: Bug #437 Stop animations when paused; tooltips: capitalize first letter (eg paper -> Paper) --- apps/openmw/engine.cpp | 3 ++- apps/openmw/mwgui/tooltips.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 617689bc63..5f1d0dd5f2 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -101,7 +101,8 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); // update world - MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); + if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) + MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 35224613ce..02a4f0c39d 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -364,6 +364,9 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) if (text.size() > 0 && text[0] == '\n') text.erase(0, 1); + if(caption.size() > 0 && isalnum(caption[0])) + caption[0] = toupper(caption[0]); + const ESM::Enchantment* enchant = 0; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (info.enchant != "") From cadc753216fda012917005c1d14c3d5b85b68698 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Sat, 3 Nov 2012 19:29:55 +0000 Subject: [PATCH 101/255] Fixed: engine: Bug #437 Stop animations when paused better fix; scene: Bug #430 Teleporting and using loading doors linking within the same cell reloads the cell Bug #437 fix only pauses the RenderingManager, and still updates the mOcclusionQuery Bug #430 fix is only tested in interiors (ToddTest) --- apps/openmw/engine.cpp | 3 +- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwrender/renderingmanager.cpp | 8 ++- apps/openmw/mwrender/renderingmanager.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 81 +++++++++++++---------- apps/openmw/mwworld/scene.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 4 +- apps/openmw/mwworld/worldimp.hpp | 2 +- 8 files changed, 60 insertions(+), 44 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 5f1d0dd5f2..a75a60223b 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -101,8 +101,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt) MWBase::Environment::get().getWorld()->doPhysics (movement, mEnvironment.getFrameDuration()); // update world - if (!MWBase::Environment::get().getWindowManager()->isGuiMode()) - MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame); + MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame, MWBase::Environment::get().getWindowManager()->isGuiMode()); // update GUI Ogre::RenderWindow* window = mOgre->getWindow(); diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index d29e23c18b..6710fc68b0 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -265,7 +265,7 @@ namespace MWBase ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - virtual void update (float duration) = 0; + virtual void update (float duration, bool paused) = 0; virtual bool placeObject(const MWWorld::Ptr& object, float cursorX, float cursorY) = 0; ///< place an object into the gameworld at the specified cursor position diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5b5fdce68e..3bf6573bd2 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -313,7 +313,7 @@ RenderingManager::moveObjectToCell( child->setPosition(pos); } -void RenderingManager::update (float duration) +void RenderingManager::update (float duration, bool paused) { Ogre::Vector3 orig, dest; mPlayer->setCameraDistance(); @@ -328,12 +328,16 @@ void RenderingManager::update (float duration) mPlayer->setCameraDistance(test.second * orig.distance(dest), false, false); } } + mOcclusionQuery->update(duration); + + if(paused) + return; + mPlayer->update(duration); mActors.update (duration); mObjects.update (duration); - mOcclusionQuery->update(duration); mSkyManager->update(duration); diff --git a/apps/openmw/mwrender/renderingmanager.hpp b/apps/openmw/mwrender/renderingmanager.hpp index 359809b71d..86346d1d6c 100644 --- a/apps/openmw/mwrender/renderingmanager.hpp +++ b/apps/openmw/mwrender/renderingmanager.hpp @@ -125,7 +125,7 @@ class RenderingManager: private RenderingInterface, public Ogre::WindowEventList /// \param store Cell the object was in previously (\a ptr has already been updated to the new cell). void moveObjectToCell (const MWWorld::Ptr& ptr, const Ogre::Vector3& position, MWWorld::CellStore *store); - void update (float duration); + void update (float duration, bool paused); void setAmbientColour(const Ogre::ColourValue& colour); void setSunColour(const Ogre::ColourValue& colour); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 517025fb2f..3982b9b12d 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -62,8 +62,8 @@ namespace namespace MWWorld { - void Scene::update (float duration){ - mRendering.update (duration); + void Scene::update (float duration, bool paused){ + mRendering.update (duration, paused); } void Scene::unloadCell (CellStoreCollection::iterator iter) @@ -306,45 +306,58 @@ namespace MWWorld { std::cout << "Changing to interior\n"; - CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); - // remove active - CellStoreCollection::iterator active = mActiveCells.begin(); - - // count number of cells to unload - int numUnload = 0; - while (active!=mActiveCells.end()) + bool loadcell = (mCurrentCell == NULL); + if(!loadcell) { - ++active; - ++numUnload; + std::string nam = std::string(cellName); + std::string curnam = std::string(mCurrentCell->cell->mName); + std::transform(nam.begin(), nam.end(), nam.begin(), ::tolower); + std::transform(curnam.begin(), curnam.end(), curnam.begin(), ::tolower); + loadcell = nam != curnam; } - - // unload - int current = 0; - active = mActiveCells.begin(); - while (active!=mActiveCells.end()) + if(loadcell) { - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); + CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); - unloadCell (active++); - ++current; + // remove active + CellStoreCollection::iterator active = mActiveCells.begin(); + + // count number of cells to unload + int numUnload = 0; + while (active!=mActiveCells.end()) + { + ++active; + ++numUnload; + } + + // unload + int current = 0; + active = mActiveCells.begin(); + while (active!=mActiveCells.end()) + { + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); + + unloadCell (active++); + ++current; + } + + // Load cell. + std::cout << "cellName:" << cellName << std::endl; + + + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); + loadCell (cell); + + mCurrentCell = cell; + + // adjust fog + mRendering.switchToInterior(); + mRendering.configureFog(*cell); } - - // Load cell. - std::cout << "cellName:" << cellName << std::endl; - - - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); - loadCell (cell); - // adjust player - mCurrentCell = cell; - playerCellChange (cell, position); - - // adjust fog - mRendering.switchToInterior(); - mRendering.configureFog(*cell); - + playerCellChange (mCurrentCell, position); + // Sky system MWBase::Environment::get().getWorld()->adjustSky(); diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 59e13dafe7..ad6ad1559e 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -88,7 +88,7 @@ namespace MWWorld void insertCell (Ptr::CellStore &cell); - void update (float duration); + void update (float duration, bool paused); void addObjectToScene (const Ptr& ptr); ///< Add an object that already exists in the world model to the scene. diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c7f0de245e..7b938be5e2 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -858,11 +858,11 @@ namespace MWWorld mRendering->skipAnimation (ptr); } - void World::update (float duration) + void World::update (float duration, bool paused) { /// \todo split this function up into subfunctions - mWorldScene->update (duration); + mWorldScene->update (duration, paused); float pitch, yaw; Ogre::Vector3 eyepos; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 527a608a6f..ad541048b9 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -280,7 +280,7 @@ namespace MWWorld ///< Skip the animation for the given MW-reference for one frame. Calls to this function for /// references that are currently not in the rendered scene should be ignored. - virtual void update (float duration); + virtual void update (float duration, bool paused); virtual bool placeObject (const Ptr& object, float cursorX, float cursorY); ///< place an object into the gameworld at the specified cursor position From ba2fc2d6f8369047d21bfdae4e0dc363c334978e Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sun, 4 Nov 2012 11:37:47 +0100 Subject: [PATCH 102/255] better fix for chargen button colors --- apps/openmw/mwgui/birth.cpp | 6 +++--- apps/openmw/mwgui/class.cpp | 6 +++--- apps/openmw/mwgui/race.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 56e566ffbc..e7862c4e7f 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -48,7 +48,7 @@ BirthDialog::BirthDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &BirthDialog::onOkClicked); - okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); + okButton->setEnabled(false); updateBirths(); updateSpells(); @@ -85,7 +85,7 @@ void BirthDialog::setBirthId(const std::string &birthId) mBirthList->setIndexSelected(i); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); break; } } @@ -114,7 +114,7 @@ void BirthDialog::onSelectBirth(MyGUI::ListBox* _sender, size_t _index) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); const std::string *birthId = mBirthList->getItemDataAt<std::string>(_index); if (boost::iequals(mCurrentBirthId, *birthId)) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index a798ca2323..f020010ec5 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -104,7 +104,7 @@ PickClassDialog::PickClassDialog(MWBase::WindowManager& parWindowManager) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PickClassDialog::onOkClicked); - okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); + okButton->setEnabled(false); updateClasses(); updateStats(); @@ -140,7 +140,7 @@ void PickClassDialog::setClassId(const std::string &classId) mClassList->setIndexSelected(i); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); break; } } @@ -169,7 +169,7 @@ void PickClassDialog::onSelectClass(MyGUI::ListBox* _sender, size_t _index) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); const std::string *classId = mClassList->getItemDataAt<std::string>(_index); if (boost::iequals(mCurrentClassId, *classId)) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index b1d51db09f..d681bc69dc 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -80,7 +80,7 @@ RaceDialog::RaceDialog(MWBase::WindowManager& parWindowManager) getWidget(okButton, "OKButton"); okButton->setCaption(mWindowManager.getGameSettingString("sOK", "")); okButton->eventMouseButtonClick += MyGUI::newDelegate(this, &RaceDialog::onOkClicked); - okButton->setTextColour(MyGUI::Colour(0.6f, 0.56f, 0.45f)); + okButton->setEnabled(false); updateRaces(); updateSkills(); @@ -124,7 +124,7 @@ void RaceDialog::setRaceId(const std::string &raceId) mRaceList->setIndexSelected(i); MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); break; } } @@ -208,7 +208,7 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) MyGUI::ButtonPtr okButton; getWidget(okButton, "OKButton"); - okButton->setTextColour(MyGUI::Colour(0.75f, 0.6f, 0.35f)); + okButton->setEnabled(true); const std::string *raceId = mRaceList->getItemDataAt<std::string>(_index); if (boost::iequals(mCurrentRaceId, *raceId)) return; From b7aa7e4cef5f27feeb76487b26404df42ad97989 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sun, 4 Nov 2012 11:57:51 +0100 Subject: [PATCH 103/255] pause all animations --- apps/openmw/mwrender/renderingmanager.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 3bf6573bd2..bcc3a311d9 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -13,6 +13,7 @@ #include <OgreCompositionTargetPass.h> #include <OgreCompositionPass.h> #include <OgreHardwarePixelBuffer.h> +#include <OgreControllerManager.h> #include <extern/shiny/Main/Factory.hpp> #include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp> @@ -331,8 +332,13 @@ void RenderingManager::update (float duration, bool paused) mOcclusionQuery->update(duration); if(paused) + { + Ogre::ControllerManager::getSingleton().setTimeFactor(0.f); return; - + } + Ogre::ControllerManager::getSingleton().setTimeFactor( + MWBase::Environment::get().getWorld()->getTimeScaleFactor()/30.f); + mPlayer->update(duration); mActors.update (duration); From 38828acac97fe39b1cb2561c3dac829f5d0946eb Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sun, 4 Nov 2012 12:13:04 +0100 Subject: [PATCH 104/255] transparent overlay --- apps/openmw/mwgui/map_window.cpp | 9 ++++++ apps/openmw/mwgui/map_window.hpp | 2 ++ apps/openmw/mwgui/windowmanagerimp.cpp | 2 ++ apps/openmw/mwrender/globalmap.cpp | 43 ++++++++++++++++++++++++++ apps/openmw/mwrender/globalmap.hpp | 9 ++++++ apps/openmw/mwrender/localmap.hpp | 1 - apps/openmw/mwrender/player.cpp | 3 +- files/mygui/openmw_map_window.layout | 1 + 8 files changed, 68 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index 1913ed8dd6..ef67037651 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -266,13 +266,17 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager, const std::string& mGlobalMapRender = new MWRender::GlobalMap(cacheDir); mGlobalMapRender->render(); + mGlobalMapRender->exploreCell(0,0); + getWidget(mLocalMap, "LocalMap"); getWidget(mGlobalMap, "GlobalMap"); getWidget(mGlobalMapImage, "GlobalMapImage"); + getWidget(mGlobalMapOverlay, "GlobalMapOverlay"); getWidget(mPlayerArrowLocal, "CompassLocal"); getWidget(mPlayerArrowGlobal, "CompassGlobal"); mGlobalMapImage->setImageTexture("GlobalMap.png"); + mGlobalMapOverlay->setImageTexture("GlobalMapOverlay"); mGlobalMap->setVisible (false); @@ -328,6 +332,11 @@ void MapWindow::addVisitedLocation(const std::string& name, int x, int y) markerWidget->setUserString("Caption_Text", name); } +void MapWindow::cellExplored(int x, int y) +{ + mGlobalMapRender->exploreCell(x,y); +} + void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id) { if (_id!=MyGUI::MouseButton::Left) return; diff --git a/apps/openmw/mwgui/map_window.hpp b/apps/openmw/mwgui/map_window.hpp index 73eaad1cd7..4e2dd67567 100644 --- a/apps/openmw/mwgui/map_window.hpp +++ b/apps/openmw/mwgui/map_window.hpp @@ -70,6 +70,7 @@ namespace MWGui void setCellName(const std::string& cellName); void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map + void cellExplored(int x, int y); virtual void open(); @@ -82,6 +83,7 @@ namespace MWGui MyGUI::ScrollView* mGlobalMap; MyGUI::ImageBox* mGlobalMapImage; + MyGUI::ImageBox* mGlobalMapOverlay; MyGUI::ImageBox* mPlayerArrowLocal; MyGUI::ImageBox* mPlayerArrowGlobal; MyGUI::Button* mButton; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 0350581e45..734b466330 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -621,6 +621,8 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) name = getGameSettingString("sDefaultCellname", "Wilderness"); } + mMap->cellExplored(cell->cell->getGridX(), cell->cell->getGridY()); + mMap->setCellName( name ); mHud->setCellName( name ); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 7a799a2e43..889e9d1894 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -7,6 +7,7 @@ #include <OgreColourValue.h> #include <OgreHardwareVertexBuffer.h> #include <OgreRoot.h> +#include <OgreHardwarePixelBuffer.h> #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -47,6 +48,7 @@ namespace MWRender mWidth = cellSize*(mMaxX-mMinX+1); mHeight = cellSize*(mMaxY-mMinY+1); + mExploredBuffer.resize((mMaxX-mMinX+1) * (mMaxY-mMinY+1) * 4); //if (!boost::filesystem::exists(mCacheDir + "/GlobalMap.png")) if (1) @@ -179,5 +181,46 @@ namespace MWRender imageY = 1.f-float(y - mMinY + 1) / (mMaxY - mMinY + 1); } + void GlobalMap::exploreCell(int cellX, int cellY) + { + mExploredCells.push_back(std::make_pair(cellX, cellY)); + int width = mMaxX-mMinX+1; + int height = mMaxY-mMinY+1; + if (mOverlayTexture.isNull()) + { + mOverlayTexture = Ogre::TextureManager::getSingleton().createManual("GlobalMapOverlay", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8B8G8R8, Ogre::TU_DYNAMIC_WRITE_ONLY); + } + + for (int x = mMinX; x <= mMaxX; ++x) + { + for (int y = mMinY; y <= mMaxY; ++y) + { + unsigned char r,g,b,a; + r = 0; + g = 0; + b = 0; + if (std::find(mExploredCells.begin(), mExploredCells.end(), std::make_pair(x, y)) != mExploredCells.end()) + a = 0; + else + a = 128; + int texelX = (x-mMinX); + int texelY = (height-1) - (y-mMinY); + + assert( static_cast<unsigned int>(texelY * width * 4 + texelX * 4+3) < mExploredBuffer.size()); + mExploredBuffer[texelY * width * 4 + texelX * 4] = r; + mExploredBuffer[texelY * width * 4 + texelX * 4+1] = g; + mExploredBuffer[texelY * width * 4 + texelX * 4+2] = b; + mExploredBuffer[texelY * width * 4 + texelX * 4+3] = a; + } + } + + Ogre::Image image; + image.loadDynamicImage(&mExploredBuffer[0], width, height, Ogre::PF_A8B8G8R8); + + memcpy(mOverlayTexture->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), + &mExploredBuffer[0], width*height*4); + mOverlayTexture->getBuffer()->unlock(); + } } diff --git a/apps/openmw/mwrender/globalmap.hpp b/apps/openmw/mwrender/globalmap.hpp index 01f5fdb9e8..c01182c5b5 100644 --- a/apps/openmw/mwrender/globalmap.hpp +++ b/apps/openmw/mwrender/globalmap.hpp @@ -3,6 +3,8 @@ #include <string> +#include <OgreTexture.h> + namespace MWRender { @@ -22,9 +24,16 @@ namespace MWRender void cellTopLeftCornerToImageSpace(int x, int y, float& imageX, float& imageY); + void exploreCell (int cellX, int cellY); + private: std::string mCacheDir; + std::vector< std::pair<int,int> > mExploredCells; + + Ogre::TexturePtr mOverlayTexture; + std::vector<Ogre::uchar> mExploredBuffer; + int mWidth; int mHeight; diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index 056d2498a3..ede221d943 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -58,7 +58,6 @@ namespace MWRender */ void saveFogOfWar(MWWorld::CellStore* cell); - /** * Get the interior map texture index and normalized position * on this texture, given a world position (in ogre coordinates) diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index bbc75cade1..d0b4641b91 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -23,7 +23,8 @@ namespace MWRender mFreeLook(true), mHeight(128.f), mCameraDistance(300.f), - mDistanceAdjusted(false) + mDistanceAdjusted(false), + mAnimation(NULL) { mVanity.enabled = false; mVanity.allowed = true; diff --git a/files/mygui/openmw_map_window.layout b/files/mygui/openmw_map_window.layout index 20cfbbd6ed..b5479b6761 100644 --- a/files/mygui/openmw_map_window.layout +++ b/files/mygui/openmw_map_window.layout @@ -19,6 +19,7 @@ <Property key="CanvasSize" value="1536 1536"/> <Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapImage"> + <Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapOverlay"/> </Widget> <Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="CompassGlobal"> From aabb1b8f3fa004faf87db6d0597559cb99ae6dda Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sun, 4 Nov 2012 13:26:04 +0100 Subject: [PATCH 105/255] Issue #219: implemented death count filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 62f7df679b..52b048b4b6 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -14,6 +14,7 @@ #include "../mwbase/scriptmanager.hpp" #include "../mwbase/journal.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/class.hpp" #include "../mwworld/refdata.hpp" @@ -368,9 +369,12 @@ namespace MWDialogue return true; - - case '6'://dead - if(!selectCompare<int,int>(comp,0,select.mI)) return false; + case '6': // dead +{ +std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name))<<std::endl; +} + return selectCompare<int,int> (comp, + MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name)), select.mI); case '7':// not ID if(select.mType==ESM::VT_String ||select.mType==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string From 6f7a621b6f4a6913950055411e1f747c8dd042f5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sun, 4 Nov 2012 23:15:20 +0100 Subject: [PATCH 106/255] disabled enchanting unfinished enchantment GUI for now --- apps/openmw/mwgui/dialogue.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 23d2197b70..96b85b4c4c 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -192,8 +192,8 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords) if (mServices & Service_CreateSpells) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellmakingMenuTitle")->getString()); - if (mServices & Service_Enchant) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); +// if (mServices & Service_Enchant) +// mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); if (mServices & Service_Training) mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()); From accf8b2f71bb52d3ddfe7384dfef4148166ed57c Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Sun, 4 Nov 2012 23:22:30 +0000 Subject: [PATCH 107/255] Updated Bug #430 fix so it only moves the player now --- apps/openmw/mwworld/scene.cpp | 94 ++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 3982b9b12d..37cc23f5ff 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -304,60 +304,62 @@ namespace MWWorld void Scene::changeToInteriorCell (const std::string& cellName, const ESM::Position& position) { - std::cout << "Changing to interior\n"; - - + CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); bool loadcell = (mCurrentCell == NULL); + if(!loadcell) + loadcell = *mCurrentCell != *cell; + if(!loadcell) { - std::string nam = std::string(cellName); - std::string curnam = std::string(mCurrentCell->cell->mName); - std::transform(nam.begin(), nam.end(), nam.begin(), ::tolower); - std::transform(curnam.begin(), curnam.end(), curnam.begin(), ::tolower); - loadcell = nam != curnam; + MWBase::World *world = MWBase::Environment::get().getWorld(); + world->moveObject(world->getPlayer().getPlayer(), position.pos[0], position.pos[1], position.pos[2]); + + float x = Ogre::Radian(position.rot[0]).valueDegrees(); + float y = Ogre::Radian(position.rot[1]).valueDegrees(); + float z = Ogre::Radian(position.rot[2]).valueDegrees(); + world->rotateObject(world->getPlayer().getPlayer(), x, y, z); + return; } - if(loadcell) + + std::cout << "Changing to interior\n"; + + // remove active + CellStoreCollection::iterator active = mActiveCells.begin(); + + // count number of cells to unload + int numUnload = 0; + while (active!=mActiveCells.end()) { - CellStore *cell = MWBase::Environment::get().getWorld()->getInterior(cellName); - - // remove active - CellStoreCollection::iterator active = mActiveCells.begin(); - - // count number of cells to unload - int numUnload = 0; - while (active!=mActiveCells.end()) - { - ++active; - ++numUnload; - } - - // unload - int current = 0; - active = mActiveCells.begin(); - while (active!=mActiveCells.end()) - { - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); - - unloadCell (active++); - ++current; - } - - // Load cell. - std::cout << "cellName:" << cellName << std::endl; - - - MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); - loadCell (cell); - - mCurrentCell = cell; - - // adjust fog - mRendering.switchToInterior(); - mRendering.configureFog(*cell); + ++active; + ++numUnload; } + + // unload + int current = 0; + active = mActiveCells.begin(); + while (active!=mActiveCells.end()) + { + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Unloading cells", 0, current, numUnload); + + unloadCell (active++); + ++current; + } + + // Load cell. + std::cout << "cellName: " << cell->cell->mName << std::endl; + + MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 0, 0, 1); + loadCell (cell); + + mCurrentCell = cell; + + // adjust fog + mRendering.switchToInterior(); + mRendering.configureFog(*mCurrentCell); + // adjust player playerCellChange (mCurrentCell, position); - + // Sky system MWBase::Environment::get().getWorld()->adjustSky(); From f72f898bd9ea8c49c143ae650bcc94b0e45c5ef4 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Mon, 5 Nov 2012 11:07:43 +0100 Subject: [PATCH 108/255] implement barterOffer. It's used for travel only. I've started to implement disposition, but it's very basic for now. --- apps/openmw/mwbase/mechanicsmanager.hpp | 6 +++ apps/openmw/mwclass/npc.cpp | 2 + apps/openmw/mwgui/travelwindow.cpp | 2 + .../mwmechanics/mechanicsmanagerimp.cpp | 52 +++++++++++++++++++ .../mwmechanics/mechanicsmanagerimp.hpp | 6 +++ apps/openmw/mwmechanics/npcstats.cpp | 12 ++++- apps/openmw/mwmechanics/npcstats.hpp | 5 ++ 7 files changed, 84 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 39d7e6e1a4..bf8d8dee48 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -74,6 +74,12 @@ namespace MWBase virtual void restoreDynamicStats() = 0; ///< If the player is sleeping, this should be called every hour. + + virtual int barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0; + ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. + + virtual int disposition(const MWWorld::Ptr& ptr) = 0; + ///< Calculate the diposition of an NPC toward the player. }; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 03b5e56aa4..4bf6c24b7a 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -94,6 +94,8 @@ namespace MWClass data->mCreatureStats.getFatigue().set (ref->base->mNpdt52.mFatigue); data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); + + data->mNpcStats.setDisposition(ref->base->mNpdt52.mDisposition); } else { diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c19639aa6a..7195ea7254 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -66,6 +66,8 @@ namespace MWGui price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); } + price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); + MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); mCurrentY += sLineHeight; /// \todo price adjustment depending on merchantile skill diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 364e653217..9a3ff610be 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -324,4 +324,56 @@ namespace MWMechanics buildPlayer(); mUpdatePlayer = true; } + + float min(float a,float b) + { + if(a<b) return a; + else return b; + } + + float max(float a,float b) + { + if(a>b) return a; + else return b; + } + + int MechanicsManager::disposition(const MWWorld::Ptr& ptr) + { + MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); + return npcSkill.getDisposition(); + } + + int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) + { + MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); + MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(ptr).getCreatureStats(ptr); + + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); + MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); + + int clampedDisposition = min(disposition(ptr),100); + float a = min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float b = min(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float c = min(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + float d = min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float e = min(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float f = min(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + + float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm(); + float npcTerm = (d + e + f) * sellerStats.getFatigueTerm(); + float buyTerm = 0.01 * (100 - 0.5 * (pcTerm - npcTerm)); + float sellTerm = 0.01 * (50 - 0.5 * (npcTerm - pcTerm)); + + float x; + if(buying) x = buyTerm; + else x = min(buyTerm, sellTerm); + std::cout << "x" << x; + int offerPrice; + if (x < 1) offerPrice = int(x * basePrice); + if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice); + offerPrice = max(1, offerPrice); + std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n"; + return offerPrice; + } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 3a41e8fa60..cdf418a81a 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -76,6 +76,12 @@ namespace MWMechanics virtual void restoreDynamicStats(); ///< If the player is sleeping, this should be called every hour. + + virtual int barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying); + ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. + + virtual int disposition(const MWWorld::Ptr& ptr); + ///< Calculate the diposition of an NPC toward the player. }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index bbd42c1471..f09b7b0bd4 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -19,7 +19,7 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing) -, mLevelProgress(0) +, mLevelProgress(0), mDisposition(0) { mSkillIncreases.resize (ESM::Attribute::Length); for (int i=0; i<ESM::Attribute::Length; ++i) @@ -36,6 +36,16 @@ void MWMechanics::NpcStats::setDrawState (DrawState_ state) mDrawState = state; } +unsigned int MWMechanics::NpcStats::getDisposition() const +{ + return mDisposition; +} + +void MWMechanics::NpcStats::setDisposition(unsigned int disposition) +{ + mDisposition = disposition; +} + bool MWMechanics::NpcStats::getMovementFlag (Flag flag) const { return mMovementFlags & flag; diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 48e63d7b6e..1fc173f903 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -43,6 +43,7 @@ namespace MWMechanics std::map<std::string, int> mFactionRank; DrawState_ mDrawState; + unsigned int mDisposition; unsigned int mMovementFlags; Stat<float> mSkill[27]; @@ -60,6 +61,10 @@ namespace MWMechanics void setDrawState (DrawState_ state); + unsigned int getDisposition() const; + + void setDisposition(unsigned int disposition); + bool getMovementFlag (Flag flag) const; void setMovementFlag (Flag flag, bool state); From 3c2ce25f5f3e889a54654cca360f10c5cfed8337 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 16:07:59 +0400 Subject: [PATCH 109/255] m prefix for mwworld/cellstore.hpp --- apps/openmw/mwclass/activator.cpp | 16 +-- apps/openmw/mwclass/apparatus.cpp | 30 ++--- apps/openmw/mwclass/armor.cpp | 46 +++---- apps/openmw/mwclass/book.cpp | 32 ++--- apps/openmw/mwclass/clothing.cpp | 42 +++--- apps/openmw/mwclass/container.cpp | 26 ++-- apps/openmw/mwclass/creature.cpp | 54 ++++---- apps/openmw/mwclass/door.cpp | 42 +++--- apps/openmw/mwclass/ingredient.cpp | 38 +++--- apps/openmw/mwclass/light.cpp | 50 ++++---- apps/openmw/mwclass/lockpick.cpp | 32 ++--- apps/openmw/mwclass/misc.cpp | 42 +++--- apps/openmw/mwclass/npc.cpp | 70 +++++----- apps/openmw/mwclass/potion.cpp | 32 ++--- apps/openmw/mwclass/probe.cpp | 32 ++--- apps/openmw/mwclass/repair.cpp | 32 ++--- apps/openmw/mwclass/static.cpp | 6 +- apps/openmw/mwclass/weapon.cpp | 72 +++++------ apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 26 ++-- apps/openmw/mwgui/bookwindow.cpp | 2 +- apps/openmw/mwgui/container.cpp | 2 +- apps/openmw/mwgui/scrollwindow.cpp | 2 +- apps/openmw/mwgui/tradewindow.cpp | 24 ++-- apps/openmw/mwgui/trainingwindow.cpp | 2 +- apps/openmw/mwgui/travelwindow.cpp | 12 +- apps/openmw/mwgui/windowmanagerimp.cpp | 22 ++-- apps/openmw/mwmechanics/alchemy.cpp | 18 +-- .../mwmechanics/mechanicsmanagerimp.cpp | 2 +- apps/openmw/mwrender/creatureanimation.cpp | 6 +- apps/openmw/mwrender/debugging.cpp | 16 +-- apps/openmw/mwrender/localmap.cpp | 10 +- apps/openmw/mwrender/npcanimation.cpp | 42 +++--- apps/openmw/mwrender/objects.cpp | 12 +- apps/openmw/mwrender/renderingmanager.cpp | 26 ++-- apps/openmw/mwrender/terrain.cpp | 8 +- apps/openmw/mwscript/cellextensions.cpp | 9 +- apps/openmw/mwscript/statsextensions.cpp | 2 +- apps/openmw/mwsound/soundmanagerimp.cpp | 8 +- apps/openmw/mwworld/actionread.cpp | 12 +- apps/openmw/mwworld/cells.cpp | 62 ++++----- apps/openmw/mwworld/cellstore.cpp | 61 ++++----- apps/openmw/mwworld/cellstore.hpp | 120 +++++++++--------- apps/openmw/mwworld/containerstore.cpp | 116 ++++++++--------- apps/openmw/mwworld/localscripts.cpp | 42 +++--- apps/openmw/mwworld/manualref.hpp | 4 +- apps/openmw/mwworld/player.cpp | 4 +- apps/openmw/mwworld/ptr.hpp | 2 +- apps/openmw/mwworld/scene.cpp | 116 +++++++++-------- apps/openmw/mwworld/weather.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 77 ++++++----- 50 files changed, 788 insertions(+), 775 deletions(-) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index e815549d8e..a7f73278ef 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -39,9 +39,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -53,7 +53,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); - return ref->base->mName; + return ref->mBase->mName; } std::string Activator::getScript (const MWWorld::Ptr& ptr) const @@ -61,7 +61,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); - return ref->base->mScript; + return ref->mBase->mScript; } void Activator::registerSelf() @@ -76,7 +76,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Activator::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -85,11 +85,11 @@ namespace MWClass ptr.get<ESM::Activator>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; return info; @@ -101,6 +101,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Activator> *ref = ptr.get<ESM::Activator>(); - return MWWorld::Ptr(&cell.activators.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mActivators.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index a05c24e864..9b2d0795ce 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -42,9 +42,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -56,7 +56,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Apparatus::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - return ref->base->mScript; + return ref->mBase->mScript; } int Apparatus::getValue (const MWWorld::Ptr& ptr) const @@ -83,7 +83,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Apparatus::registerSelf() @@ -108,7 +108,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Apparatus::hasToolTip (const MWWorld::Ptr& ptr) const @@ -116,7 +116,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Apparatus::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -125,17 +125,17 @@ namespace MWClass ptr.get<ESM::Apparatus>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -154,6 +154,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Apparatus> *ref = ptr.get<ESM::Apparatus>(); - return MWWorld::Ptr(&cell.appas.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mAppas.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 7254c37f8a..36a1b25c49 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -45,9 +45,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -59,7 +59,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Armor::activate (const MWWorld::Ptr& ptr, @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return ref->base->mData.mHealth; + return ref->mBase->mData.mHealth; } std::string Armor::getScript (const MWWorld::Ptr& ptr) const @@ -90,7 +90,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair<std::vector<int>, bool> Armor::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -118,7 +118,7 @@ namespace MWClass }; for (int i=0; i<size; ++i) - if (sMapping[i][0]==ref->base->mData.mType) + if (sMapping[i][0]==ref->mBase->mData.mType) { slots.push_back (int (sMapping[i][1])); break; @@ -134,7 +134,7 @@ namespace MWClass std::string typeGmst; - switch (ref->base->mData.mType) + switch (ref->mBase->mData.mType) { case ESM::Armor::Helmet: typeGmst = "iHelmWeight"; break; case ESM::Armor::Cuirass: typeGmst = "iCuirassWeight"; break; @@ -155,11 +155,11 @@ namespace MWClass float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->getInt(); if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->getFloat()>= - ref->base->mData.mWeight) + ref->mBase->mData.mWeight) return ESM::Skill::LightArmor; if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->getFloat()>= - ref->base->mData.mWeight) + ref->mBase->mData.mWeight) return ESM::Skill::MediumArmor; return ESM::Skill::HeavyArmor; @@ -170,7 +170,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Armor::registerSelf() @@ -207,7 +207,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Armor::hasToolTip (const MWWorld::Ptr& ptr) const @@ -215,7 +215,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Armor::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -224,8 +224,8 @@ namespace MWClass ptr.get<ESM::Armor>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; @@ -239,20 +239,20 @@ namespace MWClass else typeText = "#{sHeavy}"; - text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->base->mData.mArmor); + text += "\n#{sArmorRating}: " + MWGui::ToolTips::toString(ref->mBase->mData.mArmor); /// \todo store the current armor health somewhere - text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); + text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight) + " (" + typeText + ")"; - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")"; + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; info.text = text; @@ -264,7 +264,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr<MWWorld::Action> Armor::use (const MWWorld::Ptr& ptr) const @@ -282,6 +282,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Armor> *ref = ptr.get<ESM::Armor>(); - return MWWorld::Ptr(&cell.armors.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 4a2ad1dcb9..150865b5d9 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -41,9 +41,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -55,7 +55,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Book::activate (const MWWorld::Ptr& ptr, @@ -70,7 +70,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return ref->base->mScript; + return ref->mBase->mScript; } int Book::getValue (const MWWorld::Ptr& ptr) const @@ -78,7 +78,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Book::registerSelf() @@ -103,7 +103,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Book::hasToolTip (const MWWorld::Ptr& ptr) const @@ -111,7 +111,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Book::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -120,20 +120,20 @@ namespace MWClass ptr.get<ESM::Book>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; info.text = text; @@ -145,7 +145,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr<MWWorld::Action> Book::use (const MWWorld::Ptr& ptr) const @@ -159,6 +159,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Book> *ref = ptr.get<ESM::Book>(); - return MWWorld::Ptr(&cell.books.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index d746350dfe..ab0db50fa8 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Clothing::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair<std::vector<int>, bool> Clothing::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -85,7 +85,7 @@ namespace MWClass std::vector<int> slots; - if (ref->base->mData.mType==ESM::Clothing::Ring) + if (ref->mBase->mData.mType==ESM::Clothing::Ring) { slots.push_back (int (MWWorld::InventoryStore::Slot_LeftRing)); slots.push_back (int (MWWorld::InventoryStore::Slot_RightRing)); @@ -108,7 +108,7 @@ namespace MWClass }; for (int i=0; i<size; ++i) - if (sMapping[i][0]==ref->base->mData.mType) + if (sMapping[i][0]==ref->mBase->mData.mType) { slots.push_back (int (sMapping[i][1])); break; @@ -123,7 +123,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - if (ref->base->mData.mType==ESM::Clothing::Shoes) + if (ref->mBase->mData.mType==ESM::Clothing::Shoes) return ESM::Skill::Unarmored; return -1; @@ -134,7 +134,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Clothing::registerSelf() @@ -149,7 +149,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - if (ref->base->mData.mType == 8) + if (ref->mBase->mData.mType == 8) { return std::string("Item Ring Up"); } @@ -161,7 +161,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - if (ref->base->mData.mType == 8) + if (ref->mBase->mData.mType == 8) { return std::string("Item Ring Down"); } @@ -173,7 +173,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Clothing::hasToolTip (const MWWorld::Ptr& ptr) const @@ -181,7 +181,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Clothing::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -190,20 +190,20 @@ namespace MWClass ptr.get<ESM::Clothing>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; info.text = text; @@ -215,7 +215,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr<MWWorld::Action> Clothing::use (const MWWorld::Ptr& ptr) const @@ -233,6 +233,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Clothing> *ref = ptr.get<ESM::Clothing>(); - return MWWorld::Ptr(&cell.clothes.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 237f451f33..e4350324c5 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -74,9 +74,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -149,7 +149,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); - return ref->base->mName; + return ref->mBase->mName; } MWWorld::ContainerStore& Container::getContainerStore (const MWWorld::Ptr& ptr) @@ -165,7 +165,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); - return ref->base->mScript; + return ref->mBase->mScript; } void Container::registerSelf() @@ -180,7 +180,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Container::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -189,17 +189,17 @@ namespace MWClass ptr.get<ESM::Container>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; - if (ref->ref.mLockLevel > 0) - text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); - if (ref->ref.mTrap != "") + if (ref->mRef.mLockLevel > 0) + text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel); + if (ref->mRef.mTrap != "") text += "\n#{sTrapped}"; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -212,7 +212,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); - return ref->base->mWeight; + return ref->mBase->mWeight; } float Container::getEncumbrance (const MWWorld::Ptr& ptr) const @@ -239,6 +239,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Container> *ref = ptr.get<ESM::Container>(); - return MWWorld::Ptr(&cell.containers.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mContainers.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e4ff3c95ba..361dbc308d 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -48,28 +48,28 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); // creature stats - data->mCreatureStats.getAttribute(0).set (ref->base->mData.mStrength); - data->mCreatureStats.getAttribute(1).set (ref->base->mData.mIntelligence); - data->mCreatureStats.getAttribute(2).set (ref->base->mData.mWillpower); - data->mCreatureStats.getAttribute(3).set (ref->base->mData.mAgility); - data->mCreatureStats.getAttribute(4).set (ref->base->mData.mSpeed); - data->mCreatureStats.getAttribute(5).set (ref->base->mData.mEndurance); - data->mCreatureStats.getAttribute(6).set (ref->base->mData.mPersonality); - data->mCreatureStats.getAttribute(7).set (ref->base->mData.mLuck); - data->mCreatureStats.setHealth (ref->base->mData.mHealth); - data->mCreatureStats.setMagicka (ref->base->mData.mMana); - data->mCreatureStats.setFatigue (ref->base->mData.mFatigue); + data->mCreatureStats.getAttribute(0).set (ref->mBase->mData.mStrength); + data->mCreatureStats.getAttribute(1).set (ref->mBase->mData.mIntelligence); + data->mCreatureStats.getAttribute(2).set (ref->mBase->mData.mWillpower); + data->mCreatureStats.getAttribute(3).set (ref->mBase->mData.mAgility); + data->mCreatureStats.getAttribute(4).set (ref->mBase->mData.mSpeed); + data->mCreatureStats.getAttribute(5).set (ref->mBase->mData.mEndurance); + data->mCreatureStats.getAttribute(6).set (ref->mBase->mData.mPersonality); + data->mCreatureStats.getAttribute(7).set (ref->mBase->mData.mLuck); + data->mCreatureStats.setHealth (ref->mBase->mData.mHealth); + data->mCreatureStats.setMagicka (ref->mBase->mData.mMana); + data->mCreatureStats.setFatigue (ref->mBase->mData.mFatigue); - data->mCreatureStats.setLevel(ref->base->mData.mLevel); + data->mCreatureStats.setLevel(ref->mBase->mData.mLevel); - data->mCreatureStats.setHello(ref->base->mAiData.mHello); - data->mCreatureStats.setFight(ref->base->mAiData.mFight); - data->mCreatureStats.setFlee(ref->base->mAiData.mFlee); - data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); + data->mCreatureStats.setHello(ref->mBase->mAiData.mHello); + data->mCreatureStats.setFight(ref->mBase->mAiData.mFight); + data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee); + data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm); // spells - for (std::vector<std::string>::const_iterator iter (ref->base->mSpells.mList.begin()); - iter!=ref->base->mSpells.mList.end(); ++iter) + for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin()); + iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); // store @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - return ref->base->mId; + return ref->mBase->mId; } void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -104,9 +104,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -118,7 +118,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - return ref->base->mName; + return ref->mBase->mName; } MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const @@ -150,7 +150,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - return ref->base->mScript; + return ref->mBase->mScript; } bool Creature::isEssential (const MWWorld::Ptr& ptr) const @@ -158,7 +158,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - return ref->base->mFlags & ESM::Creature::Essential; + return ref->mBase->mFlags & ESM::Creature::Essential; } void Creature::registerSelf() @@ -181,11 +181,11 @@ namespace MWClass ptr.get<ESM::Creature>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; return info; @@ -219,6 +219,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - return MWWorld::Ptr(&cell.creatures.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mCreatures.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f944391e12..3c4b94cd97 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -44,9 +44,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -58,10 +58,10 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); - if (ref->ref.mTeleport && !ref->ref.mDestCell.empty()) // TODO doors that lead to exteriors - return ref->ref.mDestCell; + if (ref->mRef.mTeleport && !ref->mRef.mDestCell.empty()) // TODO doors that lead to exteriors + return ref->mRef.mDestCell; - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr, @@ -70,8 +70,8 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); - const std::string &openSound = ref->base->mOpenSound; - //const std::string &closeSound = ref->base->closeSound; + const std::string &openSound = ref->mBase->mOpenSound; + //const std::string &closeSound = ref->mBase->closeSound; const std::string lockedSound = "LockedDoor"; const std::string trapActivationSound = "Disarm Trap Fail"; @@ -119,13 +119,13 @@ namespace MWClass return action; } - if (ref->ref.mTeleport) + if (ref->mRef.mTeleport) { // teleport door /// \todo remove this if clause once ActionTeleport can also support other actors if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()==actor) { - boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->ref.mDestCell, ref->ref.mDoorDest)); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTeleport (ref->mRef.mDestCell, ref->mRef.mDoorDest)); action->setSound(openSound); @@ -177,7 +177,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); - return ref->base->mScript; + return ref->mBase->mScript; } void Door::registerSelf() @@ -192,7 +192,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Door::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -201,25 +201,25 @@ namespace MWClass ptr.get<ESM::Door>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - if (ref->ref.mTeleport) + if (ref->mRef.mTeleport) { std::string dest; - if (ref->ref.mDestCell != "") + if (ref->mRef.mDestCell != "") { // door leads to an interior, use interior name as tooltip - dest = ref->ref.mDestCell; + dest = ref->mRef.mDestCell; } else { // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; - MWBase::Environment::get().getWorld()->positionToIndex (ref->ref.mDoorDest.pos[0], ref->ref.mDoorDest.pos[1], x, y); + MWBase::Environment::get().getWorld()->positionToIndex (ref->mRef.mDoorDest.pos[0], ref->mRef.mDoorDest.pos[1], x, y); const ESM::Cell* cell = store.cells.findExt(x,y); if (cell->mName != "") dest = cell->mName; @@ -233,13 +233,13 @@ namespace MWClass text += "\n"+dest; } - if (ref->ref.mLockLevel > 0) - text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->ref.mLockLevel); - if (ref->ref.mTrap != "") + if (ref->mRef.mLockLevel > 0) + text += "\n#{sLockLevel}: " + MWGui::ToolTips::toString(ref->mRef.mLockLevel); + if (ref->mRef.mTrap != "") text += "\n#{sTrapped}"; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; @@ -252,6 +252,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Door> *ref = ptr.get<ESM::Door>(); - return MWWorld::Ptr(&cell.doors.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mDoors.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 45779287f4..7f87befe64 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -25,7 +25,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return ref->base->mId; + return ref->mBase->mId; } void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -50,9 +50,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -64,7 +64,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Ingredient::activate (const MWWorld::Ptr& ptr, @@ -82,7 +82,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return ref->base->mScript; + return ref->mBase->mScript; } int Ingredient::getValue (const MWWorld::Ptr& ptr) const @@ -90,7 +90,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Ingredient::hasToolTip (const MWWorld::Ptr& ptr) const @@ -133,7 +133,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Ingredient::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -142,28 +142,28 @@ namespace MWClass ptr.get<ESM::Ingredient>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } MWGui::Widgets::SpellEffectList list; for (int i=0; i<4; ++i) { - if (ref->base->mData.mEffectID[i] < 0) + if (ref->mBase->mData.mEffectID[i] < 0) continue; MWGui::Widgets::SpellEffectParams params; - params.mEffectID = ref->base->mData.mEffectID[i]; - params.mAttribute = ref->base->mData.mAttributes[i]; - params.mSkill = ref->base->mData.mSkills[i]; + params.mEffectID = ref->mBase->mData.mEffectID[i]; + params.mAttribute = ref->mBase->mData.mAttributes[i]; + params.mSkill = ref->mBase->mData.mSkills[i]; list.push_back(params); } info.effects = list; @@ -179,6 +179,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Ingredient> *ref = ptr.get<ESM::Ingredient>(); - return MWWorld::Ptr(&cell.ingreds.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mIngreds.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 6ae9ed6615..c2ac7c3424 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -27,9 +27,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; MWRender::Objects& objects = renderingInterface.getObjects(); objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false); @@ -37,11 +37,11 @@ namespace MWClass if (!model.empty()) objects.insertMesh(ptr, "meshes\\" + model); - const int color = ref->base->mData.mColor; + const int color = ref->mBase->mData.mColor; const float r = ((color >> 0) & 0xFF) / 255.0f; const float g = ((color >> 8) & 0xFF) / 255.0f; const float b = ((color >> 16) & 0xFF) / 255.0f; - const float radius = float (ref->base->mData.mRadius); + const float radius = float (ref->mBase->mData.mRadius); objects.insertLight (ptr, r, g, b, radius); } @@ -49,15 +49,15 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if(!model.empty()) { physics.insertObjectPhysics(ptr, "meshes\\" + model); } - if (!ref->base->mSound.empty()) { - MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); + if (!ref->mBase->mSound.empty()) { + MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->mBase->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); } } @@ -65,9 +65,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - assert (ref->base != NULL); + assert (ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -79,10 +79,10 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - if (ref->base->mModel.empty()) + if (ref->mBase->mModel.empty()) return ""; - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Light::activate (const MWWorld::Ptr& ptr, @@ -91,7 +91,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - if (!(ref->base->mData.mFlags & ESM::Light::Carry)) + if (!(ref->mBase->mData.mFlags & ESM::Light::Carry)) return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr)); @@ -106,7 +106,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair<std::vector<int>, bool> Light::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -116,7 +116,7 @@ namespace MWClass std::vector<int> slots; - if (ref->base->mData.mFlags & ESM::Light::Carry) + if (ref->mBase->mData.mFlags & ESM::Light::Carry) slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedLeft)); return std::make_pair (slots, false); @@ -127,7 +127,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Light::registerSelf() @@ -153,7 +153,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Light::hasToolTip (const MWWorld::Ptr& ptr) const @@ -161,7 +161,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Light::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -170,17 +170,17 @@ namespace MWClass ptr.get<ESM::Light>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -203,6 +203,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>(); - return MWWorld::Ptr(&cell.lights.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mLights.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index a0ec65c988..62cf0e8729 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Lockpick::activate (const MWWorld::Ptr& ptr, @@ -75,7 +75,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -92,7 +92,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Lockpick::registerSelf() @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Lockpick::hasToolTip (const MWWorld::Ptr& ptr) const @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Lockpick::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -134,21 +134,21 @@ namespace MWClass ptr.get<ESM::Tool>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -171,6 +171,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Tool> *ref = ptr.get<ESM::Tool>(); - return MWWorld::Ptr(&cell.lockpicks.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mLockpicks.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index edcfc7daa7..133ba1adc5 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -46,9 +46,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -60,7 +60,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Miscellaneous::activate (const MWWorld::Ptr& ptr, @@ -78,7 +78,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - return ref->base->mScript; + return ref->mBase->mScript; } int Miscellaneous::getValue (const MWWorld::Ptr& ptr) const @@ -86,7 +86,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Miscellaneous::registerSelf() @@ -101,7 +101,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { return std::string("Item Gold Up"); } @@ -113,7 +113,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - if (ref->base->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) { return std::string("Item Gold Down"); } @@ -125,7 +125,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Miscellaneous::hasToolTip (const MWWorld::Ptr& ptr) const @@ -133,7 +133,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Miscellaneous::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -147,9 +147,9 @@ namespace MWClass int count = ptr.getRefData().getCount(); - bool isGold = (ref->base->mName == store.gameSettings.find("sGold")->getString()); + bool isGold = (ref->mBase->mName == store.gameSettings.find("sGold")->getString()); if (isGold && count == 1) - count = ref->base->mData.mValue; + count = ref->mBase->mData.mValue; std::string countString; if (!isGold) @@ -157,12 +157,12 @@ namespace MWClass else // gold displays its count also if it's 1. countString = " (" + boost::lexical_cast<std::string>(count) + ")"; - info.caption = ref->base->mName + countString; - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + countString; + info.icon = ref->mBase->mIcon; - if (ref->ref.mSoul != "") + if (ref->mRef.mSoul != "") { - const ESM::Creature *creature = store.creatures.search(ref->ref.mSoul); + const ESM::Creature *creature = store.creatures.search(ref->mRef.mSoul); info.caption += " (" + creature->mName + ")"; } @@ -170,13 +170,13 @@ namespace MWClass if (!isGold) { - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); } if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -210,11 +210,11 @@ namespace MWClass MWWorld::ManualRef newRef(store, base); MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = newRef.getPtr().get<ESM::Miscellaneous>(); - newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell); + newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); } else { MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - newPtr = MWWorld::Ptr(&cell.miscItems.insert(*ref), &cell); + newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell); } return newPtr; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 2e21f8f63f..9da02895b4 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -62,39 +62,39 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); // NPC stats - if (!ref->base->mFaction.empty()) + if (!ref->mBase->mFaction.empty()) { - std::string faction = ref->base->mFaction; + std::string faction = ref->mBase->mFaction; boost::algorithm::to_lower(faction); - if(ref->base->mNpdt52.mGold != -10) + if(ref->mBase->mNpdt52.mGold != -10) { - data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt52.mRank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->mBase->mNpdt52.mRank; } else { - data->mNpcStats.getFactionRanks()[faction] = (int)ref->base->mNpdt12.mRank; + data->mNpcStats.getFactionRanks()[faction] = (int)ref->mBase->mNpdt12.mRank; } } // creature stats - if(ref->base->mNpdt52.mGold != -10) + if(ref->mBase->mNpdt52.mGold != -10) { for (int i=0; i<27; ++i) - data->mNpcStats.getSkill (i).setBase (ref->base->mNpdt52.mSkills[i]); + data->mNpcStats.getSkill (i).setBase (ref->mBase->mNpdt52.mSkills[i]); - data->mCreatureStats.getAttribute(0).set (ref->base->mNpdt52.mStrength); - data->mCreatureStats.getAttribute(1).set (ref->base->mNpdt52.mIntelligence); - data->mCreatureStats.getAttribute(2).set (ref->base->mNpdt52.mWillpower); - data->mCreatureStats.getAttribute(3).set (ref->base->mNpdt52.mAgility); - data->mCreatureStats.getAttribute(4).set (ref->base->mNpdt52.mSpeed); - data->mCreatureStats.getAttribute(5).set (ref->base->mNpdt52.mEndurance); - data->mCreatureStats.getAttribute(6).set (ref->base->mNpdt52.mPersonality); - data->mCreatureStats.getAttribute(7).set (ref->base->mNpdt52.mLuck); - data->mCreatureStats.setHealth (ref->base->mNpdt52.mHealth); - data->mCreatureStats.setMagicka (ref->base->mNpdt52.mMana); - data->mCreatureStats.setFatigue (ref->base->mNpdt52.mFatigue); + data->mCreatureStats.getAttribute(0).set (ref->mBase->mNpdt52.mStrength); + data->mCreatureStats.getAttribute(1).set (ref->mBase->mNpdt52.mIntelligence); + data->mCreatureStats.getAttribute(2).set (ref->mBase->mNpdt52.mWillpower); + data->mCreatureStats.getAttribute(3).set (ref->mBase->mNpdt52.mAgility); + data->mCreatureStats.getAttribute(4).set (ref->mBase->mNpdt52.mSpeed); + data->mCreatureStats.getAttribute(5).set (ref->mBase->mNpdt52.mEndurance); + data->mCreatureStats.getAttribute(6).set (ref->mBase->mNpdt52.mPersonality); + data->mCreatureStats.getAttribute(7).set (ref->mBase->mNpdt52.mLuck); + data->mCreatureStats.setHealth (ref->mBase->mNpdt52.mHealth); + data->mCreatureStats.setMagicka (ref->mBase->mNpdt52.mMana); + data->mCreatureStats.setFatigue (ref->mBase->mNpdt52.mFatigue); - data->mCreatureStats.setLevel(ref->base->mNpdt52.mLevel); + data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel); } else { @@ -108,14 +108,14 @@ namespace MWClass data->mCreatureStats.setLevel (1); } - data->mCreatureStats.setHello(ref->base->mAiData.mHello); - data->mCreatureStats.setFight(ref->base->mAiData.mFight); - data->mCreatureStats.setFlee(ref->base->mAiData.mFlee); - data->mCreatureStats.setAlarm(ref->base->mAiData.mAlarm); + data->mCreatureStats.setHello(ref->mBase->mAiData.mHello); + data->mCreatureStats.setFight(ref->mBase->mAiData.mFight); + data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee); + data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm); // spells - for (std::vector<std::string>::const_iterator iter (ref->base->mSpells.mList.begin()); - iter!=ref->base->mSpells.mList.end(); ++iter) + for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin()); + iter!=ref->mBase->mSpells.mList.end(); ++iter) data->mCreatureStats.getSpells().add (*iter); // store @@ -128,7 +128,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - return ref->base->mId; + return ref->mBase->mId; } void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const @@ -146,9 +146,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - std::string headID = ref->base->mHead; + std::string headID = ref->mBase->mHead; int end = headID.find_last_of("head_") - 4; std::string bodyRaceID = headID.substr(0, end); @@ -170,7 +170,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - return ref->base->mName; + return ref->mBase->mName; } MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const @@ -217,7 +217,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - return ref->base->mScript; + return ref->mBase->mScript; } void Npc::setForceStance (const MWWorld::Ptr& ptr, Stance stance, bool force) const @@ -325,7 +325,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - return ref->base->mFlags & ESM::NPC::Essential; + return ref->mBase->mFlags & ESM::NPC::Essential; } void Npc::registerSelf() @@ -347,11 +347,11 @@ namespace MWClass ptr.get<ESM::NPC>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName; + info.caption = ref->mBase->mName; std::string text; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); info.text = text; return info; @@ -396,7 +396,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - ref->base->mClass); + ref->mBase->mClass); stats.useSkill (skill, *class_, usageType); } @@ -413,6 +413,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - return MWWorld::Ptr(&cell.npcs.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mNpcs.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index f641cc7199..883ba3c6a1 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Potion::activate (const MWWorld::Ptr& ptr, @@ -76,7 +76,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - return ref->base->mScript; + return ref->mBase->mScript; } int Potion::getValue (const MWWorld::Ptr& ptr) const @@ -84,7 +84,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Potion::registerSelf() @@ -109,7 +109,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Potion::hasToolTip (const MWWorld::Ptr& ptr) const @@ -117,7 +117,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Potion::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -126,20 +126,20 @@ namespace MWClass ptr.get<ESM::Potion>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); - info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->base->mEffects); + info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->mBase->mEffects); info.isPotion = true; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -157,7 +157,7 @@ namespace MWClass MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); boost::shared_ptr<MWWorld::Action> action ( - new MWWorld::ActionApply (actor, ref->base->mId)); + new MWWorld::ActionApply (actor, ref->mBase->mId)); action->setSound ("Drink"); @@ -170,6 +170,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Potion> *ref = ptr.get<ESM::Potion>(); - return MWWorld::Ptr(&cell.potions.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mPotions.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 39472f2ec4..5a6e37385e 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Probe::activate (const MWWorld::Ptr& ptr, const MWWorld::Ptr& actor) const @@ -74,7 +74,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair<std::vector<int>, bool> Probe::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -91,7 +91,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Probe::registerSelf() @@ -116,7 +116,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Probe::hasToolTip (const MWWorld::Ptr& ptr) const @@ -124,7 +124,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Probe::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -133,21 +133,21 @@ namespace MWClass ptr.get<ESM::Probe>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -170,6 +170,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Probe> *ref = ptr.get<ESM::Probe>(); - return MWWorld::Ptr(&cell.probes.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mProbes.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 7ccb34913d..25ec7c7bac 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -41,9 +41,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -55,7 +55,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Repair::activate (const MWWorld::Ptr& ptr, @@ -73,7 +73,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - return ref->base->mScript; + return ref->mBase->mScript; } int Repair::getValue (const MWWorld::Ptr& ptr) const @@ -81,7 +81,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Repair::registerSelf() @@ -106,7 +106,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Repair::hasToolTip (const MWWorld::Ptr& ptr) const @@ -114,7 +114,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Repair::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -123,21 +123,21 @@ namespace MWClass ptr.get<ESM::Repair>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; std::string text; /// \todo store remaining uses somewhere - text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->base->mData.mUses); - text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->base->mData.mQuality); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sUses}: " + MWGui::ToolTips::toString(ref->mBase->mData.mUses); + text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -151,6 +151,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Repair> *ref = ptr.get<ESM::Repair>(); - return MWWorld::Ptr(&cell.repairs.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mRepairs.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 07ab54256e..1ef215bee0 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -33,9 +33,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -60,6 +60,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Static> *ref = ptr.get<ESM::Static>(); - return MWWorld::Ptr(&cell.statics.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mStatics.insert(*ref), &cell); } } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index fee0dfdf14..c59fb0ac6c 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -43,9 +43,9 @@ namespace MWClass { MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - assert(ref->base != NULL); + assert(ref->mBase != NULL); - const std::string &model = ref->base->mModel; + const std::string &model = ref->mBase->mModel; if (!model.empty()) { return "meshes\\" + model; } @@ -57,7 +57,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return ref->base->mName; + return ref->mBase->mName; } boost::shared_ptr<MWWorld::Action> Weapon::activate (const MWWorld::Ptr& ptr, @@ -80,7 +80,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return ref->base->mData.mHealth; + return ref->mBase->mData.mHealth; } std::string Weapon::getScript (const MWWorld::Ptr& ptr) const @@ -88,7 +88,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return ref->base->mScript; + return ref->mBase->mScript; } std::pair<std::vector<int>, bool> Weapon::getEquipmentSlots (const MWWorld::Ptr& ptr) const @@ -99,12 +99,12 @@ namespace MWClass std::vector<int> slots; bool stack = false; - if (ref->base->mData.mType==ESM::Weapon::Arrow || ref->base->mData.mType==ESM::Weapon::Bolt) + if (ref->mBase->mData.mType==ESM::Weapon::Arrow || ref->mBase->mData.mType==ESM::Weapon::Bolt) { slots.push_back (int (MWWorld::InventoryStore::Slot_Ammunition)); stack = true; } - else if (ref->base->mData.mType==ESM::Weapon::MarksmanThrown) + else if (ref->mBase->mData.mType==ESM::Weapon::MarksmanThrown) { slots.push_back (int (MWWorld::InventoryStore::Slot_CarriedRight)); stack = true; @@ -139,7 +139,7 @@ namespace MWClass }; for (int i=0; i<size; ++i) - if (sMapping[i][0]==ref->base->mData.mType) + if (sMapping[i][0]==ref->mBase->mData.mType) return sMapping[i][1]; return -1; @@ -150,7 +150,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return ref->base->mData.mValue; + return ref->mBase->mData.mValue; } void Weapon::registerSelf() @@ -165,7 +165,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - int type = ref->base->mData.mType; + int type = ref->mBase->mData.mType; // Ammo if (type == 12 || type == 13) { @@ -211,7 +211,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - int type = ref->base->mData.mType; + int type = ref->mBase->mData.mType; // Ammo if (type == 12 || type == 13) { @@ -257,7 +257,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return ref->base->mIcon; + return ref->mBase->mIcon; } bool Weapon::hasToolTip (const MWWorld::Ptr& ptr) const @@ -265,7 +265,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return (ref->base->mName != ""); + return (ref->mBase->mName != ""); } MWGui::ToolTipInfo Weapon::getToolTipInfo (const MWWorld::Ptr& ptr) const @@ -274,15 +274,15 @@ namespace MWClass ptr.get<ESM::Weapon>(); MWGui::ToolTipInfo info; - info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); - info.icon = ref->base->mIcon; + info.caption = ref->mBase->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); + info.icon = ref->mBase->mIcon; const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); std::string text; // weapon type & damage. arrows / bolts don't have his info. - if (ref->base->mData.mType < 12) + if (ref->mBase->mData.mType < 12) { text += "\n#{sType} "; @@ -300,49 +300,49 @@ namespace MWClass mapping[ESM::Weapon::MarksmanCrossbow] = std::make_pair("sSkillMarksman", ""); mapping[ESM::Weapon::MarksmanThrown] = std::make_pair("sSkillMarksman", ""); - std::string type = mapping[ref->base->mData.mType].first; - std::string oneOrTwoHanded = mapping[ref->base->mData.mType].second; + std::string type = mapping[ref->mBase->mData.mType].first; + std::string oneOrTwoHanded = mapping[ref->mBase->mData.mType].second; text += store.gameSettings.find(type)->getString() + ((oneOrTwoHanded != "") ? ", " + store.gameSettings.find(oneOrTwoHanded)->getString() : ""); // weapon damage - if (ref->base->mData.mType >= 9) + if (ref->mBase->mData.mType >= 9) { // marksman text += "\n#{sAttack}: " - + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[0])) - + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[1])); + + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[0])) + + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[1])); } else { // Chop text += "\n#{sChop}: " - + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[0])) - + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mChop[1])); + + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[0])) + + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mChop[1])); // Slash text += "\n#{sSlash}: " - + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mSlash[0])) - + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mSlash[1])); + + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mSlash[0])) + + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mSlash[1])); // Thrust text += "\n#{sThrust}: " - + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mThrust[0])) - + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->base->mData.mThrust[1])); + + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mThrust[0])) + + " - " + MWGui::ToolTips::toString(static_cast<int>(ref->mBase->mData.mThrust[1])); } } /// \todo store the current weapon health somewhere - if (ref->base->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity - text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->base->mData.mHealth); + if (ref->mBase->mData.mType < 11) // thrown weapons and arrows/bolts don't have health, only quantity + text += "\n#{sCondition}: " + MWGui::ToolTips::toString(ref->mBase->mData.mHealth); - text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->base->mData.mWeight); - text += MWGui::ToolTips::getValueString(ref->base->mData.mValue, "#{sValue}"); + text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight); + text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}"); - info.enchant = ref->base->mEnchant; + info.enchant = ref->mBase->mEnchant; if (MWBase::Environment::get().getWindowManager()->getFullHelp()) { - text += MWGui::ToolTips::getMiscString(ref->ref.mOwner, "Owner"); - text += MWGui::ToolTips::getMiscString(ref->base->mScript, "Script"); + text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner"); + text += MWGui::ToolTips::getMiscString(ref->mBase->mScript, "Script"); } info.text = text; @@ -355,7 +355,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return ref->base->mEnchant; + return ref->mBase->mEnchant; } boost::shared_ptr<MWWorld::Action> Weapon::use (const MWWorld::Ptr& ptr) const @@ -373,6 +373,6 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Weapon> *ref = ptr.get<ESM::Weapon>(); - return MWWorld::Ptr(&cell.weapons.insert(*ref), &cell); + return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell); } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 62f7df679b..8992572391 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -391,7 +391,7 @@ namespace MWDialogue if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - int isFaction = int(toLower(npc->base->mFaction) == toLower(name)); + int isFaction = int(toLower(npc->mBase->mFaction) == toLower(name)); if(selectCompare<int,int>(comp,!isFaction,select.mI)) return false; } @@ -408,7 +408,7 @@ namespace MWDialogue if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - int isClass = int(toLower(npc->base->mClass) == toLower(name)); + int isClass = int(toLower(npc->mBase->mClass) == toLower(name)); if(selectCompare<int,int>(comp,!isClass,select.mI)) return false; } @@ -425,7 +425,7 @@ namespace MWDialogue if(select.mType==ESM::VT_Int) { MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - int isRace = int(toLower(npc->base->mRace) == toLower(name)); + int isRace = int(toLower(npc->mBase->mRace) == toLower(name)); if(selectCompare<int,int>(comp,!isRace,select.mI)) return false; } @@ -438,7 +438,7 @@ namespace MWDialogue case 'B'://not Cell if(select.mType==ESM::VT_Int) { - int isCell = int(toLower(actor.getCell()->cell->mName) == toLower(name)); + int isCell = int(toLower(actor.getCell()->mCell->mName) == toLower(name)); if(selectCompare<int,int>(comp,!isCell,select.mI)) return false; } @@ -496,7 +496,7 @@ namespace MWDialogue if (!cellRef) return false; - if (toLower (info.mRace)!=toLower (cellRef->base->mRace)) + if (toLower (info.mRace)!=toLower (cellRef->mBase->mRace)) return false; } @@ -511,7 +511,7 @@ namespace MWDialogue if (!cellRef) return false; - if (toLower (info.mClass)!=toLower (cellRef->base->mClass)) + if (toLower (info.mClass)!=toLower (cellRef->mBase->mClass)) return false; } @@ -557,7 +557,7 @@ namespace MWDialogue if (!isCreature) { MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - if(npc->base->mFlags & npc->base->Female) + if(npc->mBase->mFlags & npc->mBase->Female) { if(static_cast<int> (info.mData.mGender)==0) return false; } @@ -569,7 +569,7 @@ namespace MWDialogue // check cell if (!info.mCell.empty()) - if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mName != info.mCell) + if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mName != info.mCell) return false; // TODO check DATAstruct @@ -770,14 +770,14 @@ namespace MWDialogue if (mActor.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef<ESM::NPC>* ref = mActor.get<ESM::NPC>(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } else if (mActor.getTypeName() == typeid(ESM::Creature).name()) { MWWorld::LiveCellRef<ESM::Creature>* ref = mActor.get<ESM::Creature>(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } int windowServices = 0; @@ -795,7 +795,7 @@ namespace MWDialogue || services & ESM::NPC::Misc) windowServices |= MWGui::DialogueWindow::Service_Trade; - if( !mActor.get<ESM::NPC>()->base->mTransport.empty()) + if( !mActor.get<ESM::NPC>()->mBase->mTransport.empty()) windowServices |= MWGui::DialogueWindow::Service_Travel; if (services & ESM::NPC::Spells) diff --git a/apps/openmw/mwgui/bookwindow.cpp b/apps/openmw/mwgui/bookwindow.cpp index cb142db602..bc3cd7b404 100644 --- a/apps/openmw/mwgui/bookwindow.cpp +++ b/apps/openmw/mwgui/bookwindow.cpp @@ -60,7 +60,7 @@ void BookWindow::open (MWWorld::Ptr book) MWWorld::LiveCellRef<ESM::Book> *ref = mBook.get<ESM::Book>(); BookTextParser parser; - std::vector<std::string> results = parser.split(ref->base->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); + std::vector<std::string> results = parser.split(ref->mBase->mText, mLeftPage->getSize().width, mLeftPage->getSize().height); int i=0; for (std::vector<std::string>::iterator it=results.begin(); diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index 5c202941f5..ff94e5151b 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -274,7 +274,7 @@ void ContainerBase::onContainerClicked(MyGUI::Widget* _sender) if (mPtr.getTypeName() == typeid(ESM::Container).name()) { MWWorld::LiveCellRef<ESM::Container>* ref = mPtr.get<ESM::Container>(); - if (ref->base->mFlags & ESM::Container::Organic) + if (ref->mBase->mFlags & ESM::Container::Organic) { // user notification MWBase::Environment::get().getWindowManager()-> diff --git a/apps/openmw/mwgui/scrollwindow.cpp b/apps/openmw/mwgui/scrollwindow.cpp index c839e9b736..8317025e0b 100644 --- a/apps/openmw/mwgui/scrollwindow.cpp +++ b/apps/openmw/mwgui/scrollwindow.cpp @@ -36,7 +36,7 @@ void ScrollWindow::open (MWWorld::Ptr scroll) MWWorld::LiveCellRef<ESM::Book> *ref = mScroll.get<ESM::Book>(); BookTextParser parser; - MyGUI::IntSize size = parser.parse(ref->base->mText, mTextView, 390); + MyGUI::IntSize size = parser.parse(ref->mBase->mText, mTextView, 390); if (size.height > mTextView->getSize().height) mTextView->setCanvasSize(MyGUI::IntSize(410, size.height)); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 64710c2794..0e755f49d7 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -156,15 +156,15 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); - if (ref->base->mNpdt52.mGold == -10) - merchantgold = ref->base->mNpdt12.mGold; + if (ref->mBase->mNpdt52.mGold == -10) + merchantgold = ref->mBase->mNpdt12.mGold; else - merchantgold = ref->base->mNpdt52.mGold; + merchantgold = ref->mBase->mNpdt52.mGold; } else // ESM::Creature { MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); - merchantgold = ref->base->mData.mGold; + merchantgold = ref->mBase->mData.mGold; } if (mCurrentBalance > 0 && merchantgold < mCurrentBalance) { @@ -217,15 +217,15 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); - if (ref->base->mNpdt52.mGold == -10) - merchantgold = ref->base->mNpdt12.mGold; + if (ref->mBase->mNpdt52.mGold == -10) + merchantgold = ref->mBase->mNpdt12.mGold; else - merchantgold = ref->base->mNpdt52.mGold; + merchantgold = ref->mBase->mNpdt52.mGold; } else // ESM::Creature { MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); - merchantgold = ref->base->mData.mGold; + merchantgold = ref->mBase->mData.mGold; } mMerchantGold->setCaptionWithReplacing("#{sSellerGold} " + boost::lexical_cast<std::string>(merchantgold)); @@ -261,14 +261,14 @@ namespace MWGui if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { MWWorld::LiveCellRef<ESM::NPC>* ref = mPtr.get<ESM::NPC>(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } else if (mPtr.getTypeName() == typeid(ESM::Creature).name()) { MWWorld::LiveCellRef<ESM::Creature>* ref = mPtr.get<ESM::Creature>(); - if (ref->base->mHasAI) - services = ref->base->mAiData.mServices; + if (ref->mBase->mHasAI) + services = ref->mBase->mAiData.mServices; } /// \todo what about potions, there doesn't seem to be a flag for them?? diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index af61b3487b..226167ba30 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -129,7 +129,7 @@ namespace MWGui // increase skill MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->base->mClass); + playerRef->mBase->mClass); pcStats.increaseSkill (skillId, *class_, true); // remove gold diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c19639aa6a..6431aa76ea 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -104,15 +104,15 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - for(unsigned int i = 0;i<mPtr.get<ESM::NPC>()->base->mTransport.size();i++) + for(unsigned int i = 0;i<mPtr.get<ESM::NPC>()->mBase->mTransport.size();i++) { - std::string cellname = mPtr.get<ESM::NPC>()->base->mTransport[i].mCellName; + std::string cellname = mPtr.get<ESM::NPC>()->mBase->mTransport[i].mCellName; bool interior = true; int x,y; - MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[0], - mPtr.get<ESM::NPC>()->base->mTransport[i].mPos.pos[1],x,y); - if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->cell->mName; interior= false;} - addDestination(cellname,mPtr.get<ESM::NPC>()->base->mTransport[i].mPos,interior); + MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[0], + mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[1],x,y); + if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->mCell->mName; interior= false;} + addDestination(cellname,mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos,interior); } updateLabels(); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 0350581e45..d5d88960a9 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -604,17 +604,17 @@ void WindowManager::onFrame (float frameDuration) void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) { - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) { std::string name; - if (cell->cell->mName != "") + if (cell->mCell->mName != "") { - name = cell->cell->mName; - mMap->addVisitedLocation (name, cell->cell->getGridX (), cell->cell->getGridY ()); + name = cell->mCell->mName; + mMap->addVisitedLocation (name, cell->mCell->getGridX (), cell->mCell->getGridY ()); } else { - const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->cell->mRegion); + const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->mCell->mRegion); if (region) name = region->mName; else @@ -626,15 +626,15 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) mMap->setCellPrefix("Cell"); mHud->setCellPrefix("Cell"); - mMap->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); - mHud->setActiveCell( cell->cell->mData.mX, cell->cell->mData.mY ); + mMap->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); + mHud->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); } else { - mMap->setCellName( cell->cell->mName ); - mHud->setCellName( cell->cell->mName ); - mMap->setCellPrefix( cell->cell->mName ); - mHud->setCellPrefix( cell->cell->mName ); + mMap->setCellName( cell->mCell->mName ); + mHud->setCellName( cell->mCell->mName ); + mMap->setCellPrefix( cell->mCell->mName ); + mHud->setCellPrefix( cell->mCell->mName ); } } diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 962350472e..d3564382f7 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -38,11 +38,11 @@ std::set<MWMechanics::EffectKey> MWMechanics::Alchemy::listEffects() const const MWWorld::LiveCellRef<ESM::Ingredient> *ingredient = iter->get<ESM::Ingredient>(); for (int i=0; i<4; ++i) - if (ingredient->base->mData.mEffectID[i]!=-1) + if (ingredient->mBase->mData.mEffectID[i]!=-1) { EffectKey key ( - ingredient->base->mData.mEffectID[i], ingredient->base->mData.mSkills[i]!=-1 ? - ingredient->base->mData.mSkills[i] : ingredient->base->mData.mAttributes[i]); + ingredient->mBase->mData.mEffectID[i], ingredient->mBase->mData.mSkills[i]!=-1 ? + ingredient->mBase->mData.mSkills[i] : ingredient->mBase->mData.mAttributes[i]); ++effects[key]; } @@ -77,9 +77,9 @@ void MWMechanics::Alchemy::applyTools (int flags, float& value) const else return; - float toolQuality = setup==1 || setup==2 ? mTools[tool].get<ESM::Apparatus>()->base->mData.mQuality : 0; + float toolQuality = setup==1 || setup==2 ? mTools[tool].get<ESM::Apparatus>()->mBase->mData.mQuality : 0; float calcinatorQuality = setup==1 || setup==3 ? - mTools[ESM::Apparatus::Calcinator].get<ESM::Apparatus>()->base->mData.mQuality : 0; + mTools[ESM::Apparatus::Calcinator].get<ESM::Apparatus>()->mBase->mData.mQuality : 0; float quality = 1; @@ -130,7 +130,7 @@ void MWMechanics::Alchemy::updateEffects() // general alchemy factor float x = getChance(); - x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->base->mData.mQuality; + x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality; x *= MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionStrengthMult")->getFloat(); // value @@ -258,7 +258,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name) for (TIngredientsIterator iter (beginIngredients()); iter!=endIngredients(); ++iter) if (!iter->isEmpty()) - newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->base->mData.mWeight; + newRecord.mData.mWeight += iter->get<ESM::Ingredient>()->mBase->mData.mWeight; newRecord.mData.mWeight /= countIngredients(); @@ -332,13 +332,13 @@ void MWMechanics::Alchemy::setAlchemist (const MWWorld::Ptr& npc) { MWWorld::LiveCellRef<ESM::Apparatus>* ref = iter->get<ESM::Apparatus>(); - int type = ref->base->mData.mType; + int type = ref->mBase->mData.mType; if (type<0 || type>=static_cast<int> (mTools.size())) throw std::runtime_error ("invalid apparatus type"); if (!mTools[type].isEmpty()) - if (ref->base->mData.mQuality<=mTools[type].get<ESM::Apparatus>()->base->mData.mQuality) + if (ref->mBase->mData.mQuality<=mTools[type].get<ESM::Apparatus>()->mBase->mData.mQuality) continue; mTools[type] = *iter; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 873dd94988..293b7cab1a 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -19,7 +19,7 @@ namespace MWMechanics MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (ptr).getCreatureStats (ptr); MWMechanics::NpcStats& npcStats = MWWorld::Class::get (ptr).getNpcStats (ptr); - const ESM::NPC *player = ptr.get<ESM::NPC>()->base; + const ESM::NPC *player = ptr.get<ESM::NPC>()->mBase; // reset creatureStats.setLevel(player->mNpdt52.mLevel); diff --git a/apps/openmw/mwrender/creatureanimation.cpp b/apps/openmw/mwrender/creatureanimation.cpp index afd1149723..7ee361a6f6 100644 --- a/apps/openmw/mwrender/creatureanimation.cpp +++ b/apps/openmw/mwrender/creatureanimation.cpp @@ -21,10 +21,10 @@ CreatureAnimation::CreatureAnimation(const MWWorld::Ptr& ptr): Animation() mInsert = ptr.getRefData().getBaseNode(); MWWorld::LiveCellRef<ESM::Creature> *ref = ptr.get<ESM::Creature>(); - assert (ref->base != NULL); - if(!ref->base->mModel.empty()) + assert (ref->mBase != NULL); + if(!ref->mBase->mModel.empty()) { - std::string mesh = "meshes\\" + ref->base->mModel; + std::string mesh = "meshes\\" + ref->mBase->mModel; mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, mesh); for(size_t i = 0;i < mEntityList.mEntities.size();i++) diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index 4f71507545..8f16d5f78b 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -228,22 +228,22 @@ void Debugging::togglePathgrid() void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) { - ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->cell); + ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->mCell); if (!pathgrid) return; Vector3 cellPathGridPos(0, 0, 0); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) { - cellPathGridPos.x = store->cell->mData.mX * ESM::Land::REAL_SIZE; - cellPathGridPos.y = store->cell->mData.mY * ESM::Land::REAL_SIZE; + cellPathGridPos.x = store->mCell->mData.mX * ESM::Land::REAL_SIZE; + cellPathGridPos.y = store->mCell->mData.mY * ESM::Land::REAL_SIZE; } SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos); cellPathGrid->attachObject(createPathgridLines(pathgrid)); cellPathGrid->attachObject(createPathgridPoints(pathgrid)); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) { - mExteriorPathgridNodes[std::make_pair(store->cell->mData.mX, store->cell->mData.mY)] = cellPathGrid; + mExteriorPathgridNodes[std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())] = cellPathGrid; } else { @@ -254,10 +254,10 @@ void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) void Debugging::disableCellPathgrid(MWWorld::Ptr::CellStore *store) { - if (store->cell->isExterior()) + if (store->mCell->isExterior()) { ExteriorPathgridNodes::iterator it = - mExteriorPathgridNodes.find(std::make_pair(store->cell->mData.mX, store->cell->mData.mY)); + mExteriorPathgridNodes.find(std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())); if (it != mExteriorPathgridNodes.end()) { destroyCellPathgridNode(it->second); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 1bdbce6d97..d7614a78c4 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -108,10 +108,10 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell) mCameraRotNode->setOrientation(Quaternion::IDENTITY); - std::string name = "Cell_"+coordStr(cell->cell->mData.mX, cell->cell->mData.mY); + int x = cell->mCell->getGridX(); + int y = cell->mCell->getGridY(); - int x = cell->cell->mData.mX; - int y = cell->cell->mData.mY; + std::string name = "Cell_"+coordStr(x, y); mCameraPosNode->setPosition(Vector3(0,0,0)); @@ -163,7 +163,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, const int segsX = std::ceil( length.x / sSize ); const int segsY = std::ceil( length.y / sSize ); - mInteriorName = cell->cell->mName; + mInteriorName = cell->mCell->mName; for (int x=0; x<segsX; ++x) { @@ -173,7 +173,7 @@ void LocalMap::requestMap(MWWorld::Ptr::CellStore* cell, Vector2 newcenter = start + 4096; render(newcenter.x - center.x, newcenter.y - center.y, z.y, z.x, sSize, sSize, - cell->cell->mName + "_" + coordStr(x,y)); + cell->mCell->mName + "_" + coordStr(x,y)); } } } diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 5c2b05acab..6a25818c18 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -63,18 +63,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor } const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(ref->base->mRace); + const ESM::Race *race = store.races.find(ref->mBase->mRace); - std::string hairID = ref->base->mHair; - std::string headID = ref->base->mHead; + std::string hairID = ref->mBase->mHair; + std::string headID = ref->mBase->mHead; headModel = "meshes\\" + store.bodyParts.find(headID)->mModel; hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel; - npcName = ref->base->mName; + npcName = ref->mBase->mName; - isFemale = !!(ref->base->mFlags&ESM::NPC::Female); + isFemale = !!(ref->mBase->mFlags&ESM::NPC::Female); isBeast = !!(race->mData.mFlags&ESM::Race::Beast); - bodyRaceID = "b_n_"+ref->base->mRace; + bodyRaceID = "b_n_"+ref->mBase->mRace; std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); @@ -170,7 +170,7 @@ void NpcAnimation::updateParts() { MWWorld::Ptr ptr = *robe; - const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Robe, 5, parts); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Robe, 5); @@ -190,7 +190,7 @@ void NpcAnimation::updateParts() { MWWorld::Ptr ptr = *skirtiter; - const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Skirt, 4, parts); reserveIndividualPart(ESM::PRT_Groin, MWWorld::InventoryStore::Slot_Skirt, 4); @@ -201,32 +201,32 @@ void NpcAnimation::updateParts() if(helmet != mInv.end()) { removeIndividualPart(ESM::PRT_Hair); - const ESM::Armor *armor = (helmet->get<ESM::Armor>())->base; + const ESM::Armor *armor = (helmet->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); } if(cuirass != mInv.end()) { - const ESM::Armor *armor = (cuirass->get<ESM::Armor>())->base; + const ESM::Armor *armor = (cuirass->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); } if(greaves != mInv.end()) { - const ESM::Armor *armor = (greaves->get<ESM::Armor>())->base; + const ESM::Armor *armor = (greaves->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); } if(leftpauldron != mInv.end()) { - const ESM::Armor *armor = (leftpauldron->get<ESM::Armor>())->base; + const ESM::Armor *armor = (leftpauldron->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); } if(rightpauldron != mInv.end()) { - const ESM::Armor *armor = (rightpauldron->get<ESM::Armor>())->base; + const ESM::Armor *armor = (rightpauldron->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } @@ -234,13 +234,13 @@ void NpcAnimation::updateParts() { if(boots->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (boots->get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (boots->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } else if(boots->getTypeName() == typeid(ESM::Armor).name()) { - const ESM::Armor *armor = (boots->get<ESM::Armor>())->base; + const ESM::Armor *armor = (boots->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); } @@ -249,13 +249,13 @@ void NpcAnimation::updateParts() { if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (leftglove->get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (leftglove->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); } else { - const ESM::Armor *armor = (leftglove->get<ESM::Armor>())->base; + const ESM::Armor *armor = (leftglove->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); } @@ -264,13 +264,13 @@ void NpcAnimation::updateParts() { if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (rightglove->get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (rightglove->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); } else { - const ESM::Armor *armor = (rightglove->get<ESM::Armor>())->base; + const ESM::Armor *armor = (rightglove->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); } @@ -279,13 +279,13 @@ void NpcAnimation::updateParts() if(shirt != mInv.end()) { - const ESM::Clothing *clothes = (shirt->get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (shirt->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } if(pants != mInv.end()) { - const ESM::Clothing *clothes = (pants->get<ESM::Clothing>())->base; + const ESM::Clothing *clothes = (pants->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); } diff --git a/apps/openmw/mwrender/objects.cpp b/apps/openmw/mwrender/objects.cpp index 69c853d86b..36f09e6d96 100644 --- a/apps/openmw/mwrender/objects.cpp +++ b/apps/openmw/mwrender/objects.cpp @@ -219,18 +219,18 @@ void Objects::insertLight (const MWWorld::Ptr& ptr, float r, float g, float b, f info.radius = radius; info.colour = Ogre::ColourValue(r, g, b); - if (ref->base->mData.mFlags & ESM::Light::Negative) + if (ref->mBase->mData.mFlags & ESM::Light::Negative) info.colour *= -1; - info.interior = (ptr.getCell()->cell->mData.mFlags & ESM::Cell::Interior); + info.interior = !ptr.getCell()->mCell->isExterior(); - if (ref->base->mData.mFlags & ESM::Light::Flicker) + if (ref->mBase->mData.mFlags & ESM::Light::Flicker) info.type = LT_Flicker; - else if (ref->base->mData.mFlags & ESM::Light::FlickerSlow) + else if (ref->mBase->mData.mFlags & ESM::Light::FlickerSlow) info.type = LT_FlickerSlow; - else if (ref->base->mData.mFlags & ESM::Light::Pulse) + else if (ref->mBase->mData.mFlags & ESM::Light::Pulse) info.type = LT_Pulse; - else if (ref->base->mData.mFlags & ESM::Light::PulseSlow) + else if (ref->mBase->mData.mFlags & ESM::Light::PulseSlow) info.type = LT_PulseSlow; else info.type = LT_Normal; diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5b5fdce68e..32389c7bd1 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -206,7 +206,7 @@ void RenderingManager::removeCell (MWWorld::Ptr::CellStore *store) mObjects.removeCell(store); mActors.removeCell(store); mDebugging->cellRemoved(store); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) mTerrainManager->cellRemoved(store); } @@ -227,7 +227,7 @@ void RenderingManager::cellAdded (MWWorld::Ptr::CellStore *store) { mObjects.buildStaticGeometry (*store); mDebugging->cellAdded(store); - if (store->cell->isExterior()) + if (store->mCell->isExterior()) mTerrainManager->cellAdded(store); waterAdded(store); } @@ -366,7 +366,7 @@ void RenderingManager::update (float duration) mWater->updateUnderwater( world->isUnderwater( - *world->getPlayer().getPlayer().getCell()->cell, + *world->getPlayer().getPlayer().getCell()->mCell, Ogre::Vector3(cam.x, -cam.z, cam.y)) ); mWater->update(duration); @@ -374,14 +374,14 @@ void RenderingManager::update (float duration) } void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ - if(store->cell->mData.mFlags & store->cell->HasWater - || ((!(store->cell->mData.mFlags & ESM::Cell::Interior)) - && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->cell->mData.mX,store->cell->mData.mY) )) // always use water, if the cell does not have land. + if(store->mCell->mData.mFlags & store->mCell->HasWater + || ((store->mCell->isExterior()) + && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->mCell->getGridX(),store->mCell->getGridY()) )) // always use water, if the cell does not have land. { if(mWater == 0) - mWater = new MWRender::Water(mRendering.getCamera(), this, store->cell); + mWater = new MWRender::Water(mRendering.getCamera(), this, store->mCell); else - mWater->changeCell(store->cell); + mWater->changeCell(store->mCell); mWater->setActive(true); } else @@ -467,9 +467,9 @@ bool RenderingManager::toggleRenderMode(int mode) void RenderingManager::configureFog(MWWorld::Ptr::CellStore &mCell) { Ogre::ColourValue color; - color.setAsABGR (mCell.cell->mAmbi.mFog); + color.setAsABGR (mCell.mCell->mAmbi.mFog); - configureFog(mCell.cell->mAmbi.mFogDensity, color); + configureFog(mCell.mCell->mAmbi.mFogDensity, color); if (mWater) mWater->setViewportBackground (Ogre::ColourValue(0.8f, 0.9f, 1.0f)); @@ -519,7 +519,7 @@ void RenderingManager::setAmbientMode() void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) { - mAmbientColor.setAsABGR (mCell.cell->mAmbi.mAmbient); + mAmbientColor.setAsABGR (mCell.mCell->mAmbi.mAmbient); setAmbientMode(); // Create a "sun" that shines light downwards. It doesn't look @@ -529,7 +529,7 @@ void RenderingManager::configureAmbient(MWWorld::Ptr::CellStore &mCell) mSun = mRendering.getScene()->createLight(); } Ogre::ColourValue colour; - colour.setAsABGR (mCell.cell->mAmbi.mSunlight); + colour.setAsABGR (mCell.mCell->mAmbi.mSunlight); mSun->setDiffuseColour (colour); mSun->setType(Ogre::Light::LT_DIRECTIONAL); mSun->setDirection(0,-1,0); @@ -613,7 +613,7 @@ void RenderingManager::setGlare(bool glare) void RenderingManager::requestMap(MWWorld::Ptr::CellStore* cell) { - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) mLocalMap->requestMap(cell); else mLocalMap->requestMap(cell, mObjects.getDimensions(cell)); diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 114a9bc375..eaea3d0ecf 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -92,8 +92,8 @@ namespace MWRender void TerrainManager::cellAdded(MWWorld::Ptr::CellStore *store) { - const int cellX = store->cell->getGridX(); - const int cellY = store->cell->getGridY(); + const int cellX = store->mCell->getGridX(); + const int cellY = store->mCell->getGridY(); ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); if (land == NULL) // no land data means we're not going to create any terrain. @@ -188,8 +188,8 @@ namespace MWRender { for ( int y = 0; y < 2; y++ ) { - int terrainX = store->cell->getGridX() * 2 + x; - int terrainY = store->cell->getGridY() * 2 + y; + int terrainX = store->mCell->getGridX() * 2 + x; + int terrainY = store->mCell->getGridY() * 2 + y; if (mTerrainGroup.getTerrain(terrainX, terrainY) != NULL) mTerrainGroup.unloadTerrain(terrainX, terrainY); } diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 57dd7962b2..a9c31b7fe5 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -87,8 +87,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { bool interior = - MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mData.mFlags & - ESM::Cell::Interior; + !MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->isExterior(); runtime.push (interior ? 1 : 0); } @@ -103,7 +102,7 @@ namespace MWScript std::string name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell; + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell; std::string current = cell->mName; @@ -143,7 +142,7 @@ namespace MWScript MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel = level; @@ -161,7 +160,7 @@ namespace MWScript MWWorld::Ptr::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell(); - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel +=level; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 0d69608e1c..828d8a5e07 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -328,7 +328,7 @@ namespace MWScript assert (ref); const ESM::Class& class_ = - *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->base->mClass); + *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->mBase->mClass); float level = 0; float progress = std::modf (stats.getSkill (mIndex).getBase(), &level); diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 5d5ef3d1d0..9aabffb987 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -414,13 +414,13 @@ namespace MWSound //If the region has changed timePassed += duration; - if((current->cell->mData.mFlags & current->cell->Interior) || timePassed < 10) + if(!current->mCell->isExterior() || timePassed < 10) return; timePassed = 0; - if(regionName != current->cell->mRegion) + if(regionName != current->mCell->mRegion) { - regionName = current->cell->mRegion; + regionName = current->mCell->mRegion; total = 0; } @@ -477,7 +477,7 @@ namespace MWSound MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - const ESM::Cell *cell = player.getCell()->cell; + const ESM::Cell *cell = player.getCell()->mCell; Environment env = Env_Normal; if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater) diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 4ac613df7f..92f2328023 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -24,7 +24,7 @@ namespace MWWorld { LiveCellRef<ESM::Book> *ref = getTarget().get<ESM::Book>(); - if (ref->base->mData.mIsScroll) + if (ref->mBase->mData.mIsScroll) { MWBase::Environment::get().getWindowManager()->pushGuiMode(MWGui::GM_Scroll); MWBase::Environment::get().getWindowManager()->getScrollWindow()->open(getTarget()); @@ -39,16 +39,16 @@ namespace MWWorld MWMechanics::NpcStats& npcStats = MWWorld::Class::get(player).getNpcStats (player); // Skill gain from books - if (ref->base->mData.mSkillID >= 0 && ref->base->mData.mSkillID < ESM::Skill::Length - && !npcStats.hasBeenUsed (ref->base->mId)) + if (ref->mBase->mData.mSkillID >= 0 && ref->mBase->mData.mSkillID < ESM::Skill::Length + && !npcStats.hasBeenUsed (ref->mBase->mId)) { MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->base->mClass); + playerRef->mBase->mClass); - npcStats.increaseSkill (ref->base->mData.mSkillID, *class_, true); + npcStats.increaseSkill (ref->mBase->mData.mSkillID, *class_, true); - npcStats.flagAsUsed (ref->base->mId); + npcStats.flagAsUsed (ref->mBase->mId); } } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index e5a38d4be1..0279c74808 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -24,12 +24,12 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) else { std::map<std::pair<int, int>, Ptr::CellStore>::iterator result = - mExteriors.find (std::make_pair (cell->mData.mX, cell->mData.mY)); + mExteriors.find (std::make_pair (cell->getGridX(), cell->getGridY())); if (result==mExteriors.end()) { result = mExteriors.insert (std::make_pair ( - std::make_pair (cell->mData.mX, cell->mData.mY), Ptr::CellStore (cell))).first; + std::make_pair (cell->getGridX(), cell->getGridY()), Ptr::CellStore (cell))).first; } @@ -40,33 +40,33 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) void MWWorld::Cells::fillContainers (Ptr::CellStore& cellStore) { for (CellRefList<ESM::Container>::List::iterator iter ( - cellStore.containers.list.begin()); - iter!=cellStore.containers.list.end(); ++iter) + cellStore.mContainers.mList.begin()); + iter!=cellStore.mContainers.mList.end(); ++iter) { Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->mInventory, mStore); + iter->mBase->mInventory, mStore); } for (CellRefList<ESM::Creature>::List::iterator iter ( - cellStore.creatures.list.begin()); - iter!=cellStore.creatures.list.end(); ++iter) + cellStore.mCreatures.mList.begin()); + iter!=cellStore.mCreatures.mList.end(); ++iter) { Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->mInventory, mStore); + iter->mBase->mInventory, mStore); } for (CellRefList<ESM::NPC>::List::iterator iter ( - cellStore.npcs.list.begin()); - iter!=cellStore.npcs.list.end(); ++iter) + cellStore.mNpcs.mList.begin()); + iter!=cellStore.mNpcs.mList.end(); ++iter) { Ptr container (&*iter, &cellStore); Class::get (container).getContainerStore (container).fill ( - iter->base->mInventory, mStore); + iter->mBase->mInventory, mStore); } } @@ -169,64 +169,64 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& ce } MWWorld::Ptr ptr; - if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.activators.find (name)) + if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.mActivators.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.potions.find (name)) + if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.mPotions.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.appas.find (name)) + if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.mAppas.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.armors.find (name)) + if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.mArmors.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.books.find (name)) + if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.mBooks.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.clothes.find (name)) + if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.mClothes.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.containers.find (name)) + if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.mContainers.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.creatures.find (name)) + if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.mCreatures.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.doors.find (name)) + if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.mDoors.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.ingreds.find (name)) + if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.mIngreds.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.creatureLists.find (name)) + if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.mCreatureLists.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.itemLists.find (name)) + if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.mItemLists.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.lights.find (name)) + if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.mLights.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Tool> *ref = cell.lockpicks.find (name)) + if (MWWorld::LiveCellRef<ESM::Tool> *ref = cell.mLockpicks.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.miscItems.find (name)) + if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.mMiscItems.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.npcs.find (name)) + if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.mNpcs.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.probes.find (name)) + if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.mProbes.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.repairs.find (name)) + if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.mRepairs.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.statics.find (name)) + if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.mStatics.find (name)) ptr = Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.weapons.find (name)) + if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.mWeapons.find (name)) ptr = Ptr (ref, &cell); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) { diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index fcdec1e7f0..e0b4355568 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -11,7 +11,8 @@ namespace MWWorld { - CellStore::CellStore (const ESM::Cell *cell_) : cell (cell_), mState (State_Unloaded) + CellStore::CellStore (const ESM::Cell *cell) + : mCell (cell), mState (State_Unloaded) { mWaterLevel = cell->mWater; } @@ -23,7 +24,7 @@ namespace MWWorld if (mState==State_Preloaded) mIds.clear(); - std::cout << "loading cell " << cell->getDescription() << std::endl; + std::cout << "loading cell " << mCell->getDescription() << std::endl; loadRefs (store, esm); @@ -43,18 +44,18 @@ namespace MWWorld void CellStore::listRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) { - assert (cell); + assert (mCell); - if (cell->mContext.filename.empty()) + if (mCell->mContext.filename.empty()) return; // this is a dynamically generated cell -> skipping. // Reopen the ESM reader and seek to the right position. - cell->restore (esm); + mCell->restore (esm); ESM::CellRef ref; // Get each reference in turn - while (cell->getNextRef (esm, ref)) + while (mCell->getNextRef (esm, ref)) { std::string lowerCase; @@ -69,18 +70,18 @@ namespace MWWorld void CellStore::loadRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) { - assert (cell); + assert (mCell); - if (cell->mContext.filename.empty()) + if (mCell->mContext.filename.empty()) return; // this is a dynamically generated cell -> skipping. // Reopen the ESM reader and seek to the right position. - cell->restore(esm); + mCell->restore(esm); ESM::CellRef ref; // Get each reference in turn - while(cell->getNextRef(esm, ref)) + while(mCell->getNextRef(esm, ref)) { std::string lowerCase; @@ -98,26 +99,26 @@ namespace MWWorld */ switch(rec) { - case ESM::REC_ACTI: activators.find(ref, store.activators); break; - case ESM::REC_ALCH: potions.find(ref, store.potions); break; - case ESM::REC_APPA: appas.find(ref, store.appas); break; - case ESM::REC_ARMO: armors.find(ref, store.armors); break; - case ESM::REC_BOOK: books.find(ref, store.books); break; - case ESM::REC_CLOT: clothes.find(ref, store.clothes); break; - case ESM::REC_CONT: containers.find(ref, store.containers); break; - case ESM::REC_CREA: creatures.find(ref, store.creatures); break; - case ESM::REC_DOOR: doors.find(ref, store.doors); break; - case ESM::REC_INGR: ingreds.find(ref, store.ingreds); break; - case ESM::REC_LEVC: creatureLists.find(ref, store.creatureLists); break; - case ESM::REC_LEVI: itemLists.find(ref, store.itemLists); break; - case ESM::REC_LIGH: lights.find(ref, store.lights); break; - case ESM::REC_LOCK: lockpicks.find(ref, store.lockpicks); break; - case ESM::REC_MISC: miscItems.find(ref, store.miscItems); break; - case ESM::REC_NPC_: npcs.find(ref, store.npcs); break; - case ESM::REC_PROB: probes.find(ref, store.probes); break; - case ESM::REC_REPA: repairs.find(ref, store.repairs); break; - case ESM::REC_STAT: statics.find(ref, store.statics); break; - case ESM::REC_WEAP: weapons.find(ref, store.weapons); break; + case ESM::REC_ACTI: mActivators.find(ref, store.activators); break; + case ESM::REC_ALCH: mPotions.find(ref, store.potions); break; + case ESM::REC_APPA: mAppas.find(ref, store.appas); break; + case ESM::REC_ARMO: mArmors.find(ref, store.armors); break; + case ESM::REC_BOOK: mBooks.find(ref, store.books); break; + case ESM::REC_CLOT: mClothes.find(ref, store.clothes); break; + case ESM::REC_CONT: mContainers.find(ref, store.containers); break; + case ESM::REC_CREA: mCreatures.find(ref, store.creatures); break; + case ESM::REC_DOOR: mDoors.find(ref, store.doors); break; + case ESM::REC_INGR: mIngreds.find(ref, store.ingreds); break; + case ESM::REC_LEVC: mCreatureLists.find(ref, store.creatureLists); break; + case ESM::REC_LEVI: mItemLists.find(ref, store.itemLists); break; + case ESM::REC_LIGH: mLights.find(ref, store.lights); break; + case ESM::REC_LOCK: mLockpicks.find(ref, store.lockpicks); break; + case ESM::REC_MISC: mMiscItems.find(ref, store.miscItems); break; + case ESM::REC_NPC_: mNpcs.find(ref, store.npcs); break; + case ESM::REC_PROB: mProbes.find(ref, store.probes); break; + case ESM::REC_REPA: mRepairs.find(ref, store.repairs); break; + case ESM::REC_STAT: mStatics.find(ref, store.statics); break; + case ESM::REC_WEAP: mWeapons.find(ref, store.weapons); break; case 0: std::cout << "Cell reference " + ref.mRefID + " not found!\n"; break; default: diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 32ab6e07b9..c48e90d314 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -26,19 +26,21 @@ namespace MWWorld template <typename X> struct LiveCellRef { - LiveCellRef(const ESM::CellRef& cref, const X* b = NULL) : base(b), ref(cref), - mData(ref) {} + LiveCellRef(const ESM::CellRef& cref, const X* b = NULL) + : mBase(b), mRef(cref), mData(mRef) + {} - - LiveCellRef(const X* b = NULL) : base(b), mData(ref) {} + LiveCellRef(const X* b = NULL) + : mBase(b), mData(mRef) + {} // The object that this instance is based on. - const X* base; + const X* mBase; /* Information about this instance, such as 3D location and rotation and individual type-dependent data. */ - ESM::CellRef ref; + ESM::CellRef mRef; /// runtime-data RefData mData; @@ -50,7 +52,7 @@ namespace MWWorld { typedef LiveCellRef<X> LiveRef; typedef std::list<LiveRef> List; - List list; + List mList; // Search for the given reference in the given reclist from // ESMStore. Insert the reference into the list if a match is @@ -62,14 +64,14 @@ namespace MWWorld if(obj == NULL) throw std::runtime_error("Error resolving cell reference " + ref.mRefID); - list.push_back(LiveRef(ref, obj)); + mList.push_back(LiveRef(ref, obj)); } LiveRef *find (const std::string& name) { - for (typename std::list<LiveRef>::iterator iter (list.begin()); iter!=list.end(); ++iter) + for (typename std::list<LiveRef>::iterator iter (mList.begin()); iter!=mList.end(); ++iter) { - if (iter->mData.getCount() > 0 && iter->ref.mRefID == name) + if (iter->mData.getCount() > 0 && iter->mRef.mRefID == name) return &*iter; } @@ -77,8 +79,8 @@ namespace MWWorld } LiveRef &insert(const LiveRef &item) { - list.push_back(item); - return list.back(); + mList.push_back(item); + return mList.back(); } }; @@ -94,33 +96,33 @@ namespace MWWorld CellStore (const ESM::Cell *cell_); - const ESM::Cell *cell; + const ESM::Cell *mCell; State mState; std::vector<std::string> mIds; float mWaterLevel; // Lists for each individual object type - CellRefList<ESM::Activator> activators; - CellRefList<ESM::Potion> potions; - CellRefList<ESM::Apparatus> appas; - CellRefList<ESM::Armor> armors; - CellRefList<ESM::Book> books; - CellRefList<ESM::Clothing> clothes; - CellRefList<ESM::Container> containers; - CellRefList<ESM::Creature> creatures; - CellRefList<ESM::Door> doors; - CellRefList<ESM::Ingredient> ingreds; - CellRefList<ESM::CreatureLevList> creatureLists; - CellRefList<ESM::ItemLevList> itemLists; - CellRefList<ESM::Light> lights; - CellRefList<ESM::Tool> lockpicks; - CellRefList<ESM::Miscellaneous> miscItems; - CellRefList<ESM::NPC> npcs; - CellRefList<ESM::Probe> probes; - CellRefList<ESM::Repair> repairs; - CellRefList<ESM::Static> statics; - CellRefList<ESM::Weapon> weapons; + CellRefList<ESM::Activator> mActivators; + CellRefList<ESM::Potion> mPotions; + CellRefList<ESM::Apparatus> mAppas; + CellRefList<ESM::Armor> mArmors; + CellRefList<ESM::Book> mBooks; + CellRefList<ESM::Clothing> mClothes; + CellRefList<ESM::Container> mContainers; + CellRefList<ESM::Creature> mCreatures; + CellRefList<ESM::Door> mDoors; + CellRefList<ESM::Ingredient> mIngreds; + CellRefList<ESM::CreatureLevList> mCreatureLists; + CellRefList<ESM::ItemLevList> mItemLists; + CellRefList<ESM::Light> mLights; + CellRefList<ESM::Tool> mLockpicks; + CellRefList<ESM::Miscellaneous> mMiscItems; + CellRefList<ESM::NPC> mNpcs; + CellRefList<ESM::Probe> mProbes; + CellRefList<ESM::Repair> mRepairs; + CellRefList<ESM::Static> mStatics; + CellRefList<ESM::Weapon> mWeapons; void load (const ESMS::ESMStore &store, ESM::ESMReader &esm); @@ -133,32 +135,32 @@ namespace MWWorld bool forEach (Functor& functor) { return - forEachImp (functor, activators) && - forEachImp (functor, potions) && - forEachImp (functor, appas) && - forEachImp (functor, armors) && - forEachImp (functor, books) && - forEachImp (functor, clothes) && - forEachImp (functor, containers) && - forEachImp (functor, creatures) && - forEachImp (functor, doors) && - forEachImp (functor, ingreds) && - forEachImp (functor, creatureLists) && - forEachImp (functor, itemLists) && - forEachImp (functor, lights) && - forEachImp (functor, lockpicks) && - forEachImp (functor, miscItems) && - forEachImp (functor, npcs) && - forEachImp (functor, probes) && - forEachImp (functor, repairs) && - forEachImp (functor, statics) && - forEachImp (functor, weapons); + forEachImp (functor, mActivators) && + forEachImp (functor, mPotions) && + forEachImp (functor, mAppas) && + forEachImp (functor, mArmors) && + forEachImp (functor, mBooks) && + forEachImp (functor, mClothes) && + forEachImp (functor, mContainers) && + forEachImp (functor, mCreatures) && + forEachImp (functor, mDoors) && + forEachImp (functor, mIngreds) && + forEachImp (functor, mCreatureLists) && + forEachImp (functor, mItemLists) && + forEachImp (functor, mLights) && + forEachImp (functor, mLockpicks) && + forEachImp (functor, mMiscItems) && + forEachImp (functor, mNpcs) && + forEachImp (functor, mProbes) && + forEachImp (functor, mRepairs) && + forEachImp (functor, mStatics) && + forEachImp (functor, mWeapons); } bool operator==(const CellStore &cell) { - return this->cell->mName == cell.cell->mName && - this->cell->mData.mX == cell.cell->mData.mX && - this->cell->mData.mY == cell.cell->mData.mY; + return mCell->mName == cell.mCell->mName && + mCell->mData.mX == cell.mCell->mData.mX && + mCell->mData.mY == cell.mCell->mData.mY; } bool operator!=(const CellStore &cell) { @@ -166,7 +168,7 @@ namespace MWWorld } bool isExterior() const { - return cell->isExterior(); + return mCell->isExterior(); } private: @@ -174,9 +176,9 @@ namespace MWWorld template<class Functor, class List> bool forEachImp (Functor& functor, List& list) { - for (typename List::List::iterator iter (list.list.begin()); iter!=list.list.end(); + for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end(); ++iter) - if (!functor (iter->ref, iter->mData)) + if (!functor (iter->mRef, iter->mData)) return false; return true; diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 5c4dd03a45..78454be4b0 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -24,12 +24,12 @@ namespace float sum = 0; for (typename MWWorld::CellRefList<T>::List::const_iterator iter ( - cellRefList.list.begin()); - iter!=cellRefList.list.end(); + cellRefList.mList.begin()); + iter!=cellRefList.mList.end(); ++iter) { if (iter->mData.getCount()>0) - sum += iter->mData.getCount()*iter->base->mData.mWeight; + sum += iter->mData.getCount()*iter->mBase->mData.mWeight; } return sum; @@ -81,19 +81,19 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) MWWorld::LiveCellRef<ESM::Miscellaneous> *gold = ptr.get<ESM::Miscellaneous>(); - if (compare_string_ci(gold->ref.mRefID, "gold_001") - || compare_string_ci(gold->ref.mRefID, "gold_005") - || compare_string_ci(gold->ref.mRefID, "gold_010") - || compare_string_ci(gold->ref.mRefID, "gold_025") - || compare_string_ci(gold->ref.mRefID, "gold_100")) + if (compare_string_ci(gold->mRef.mRefID, "gold_001") + || compare_string_ci(gold->mRef.mRefID, "gold_005") + || compare_string_ci(gold->mRef.mRefID, "gold_010") + || compare_string_ci(gold->mRef.mRefID, "gold_025") + || compare_string_ci(gold->mRef.mRefID, "gold_100")) { MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); - int count = (ptr.getRefData().getCount() == 1) ? gold->base->mData.mValue : ptr.getRefData().getCount(); + int count = (ptr.getRefData().getCount() == 1) ? gold->mBase->mData.mValue : ptr.getRefData().getCount(); ref.getPtr().getRefData().setCount(count); for (MWWorld::ContainerStoreIterator iter (begin(type)); iter!=end(); ++iter) { - if (compare_string_ci((*iter).get<ESM::Miscellaneous>()->ref.mRefID, "gold_001")) + if (compare_string_ci((*iter).get<ESM::Miscellaneous>()->mRef.mRefID, "gold_001")) { (*iter).getRefData().setCount( (*iter).getRefData().getCount() + count); flagAsModified(); @@ -127,18 +127,18 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImpl (const Ptr& ptr switch (getType(ptr)) { - case Type_Potion: potions.list.push_back (*ptr.get<ESM::Potion>()); it = ContainerStoreIterator(this, --potions.list.end()); break; - case Type_Apparatus: appas.list.push_back (*ptr.get<ESM::Apparatus>()); it = ContainerStoreIterator(this, --appas.list.end()); break; - case Type_Armor: armors.list.push_back (*ptr.get<ESM::Armor>()); it = ContainerStoreIterator(this, --armors.list.end()); break; - case Type_Book: books.list.push_back (*ptr.get<ESM::Book>()); it = ContainerStoreIterator(this, --books.list.end()); break; - case Type_Clothing: clothes.list.push_back (*ptr.get<ESM::Clothing>()); it = ContainerStoreIterator(this, --clothes.list.end()); break; - case Type_Ingredient: ingreds.list.push_back (*ptr.get<ESM::Ingredient>()); it = ContainerStoreIterator(this, --ingreds.list.end()); break; - case Type_Light: lights.list.push_back (*ptr.get<ESM::Light>()); it = ContainerStoreIterator(this, --lights.list.end()); break; - case Type_Lockpick: lockpicks.list.push_back (*ptr.get<ESM::Tool>()); it = ContainerStoreIterator(this, --lockpicks.list.end()); break; - case Type_Miscellaneous: miscItems.list.push_back (*ptr.get<ESM::Miscellaneous>()); it = ContainerStoreIterator(this, --miscItems.list.end()); break; - case Type_Probe: probes.list.push_back (*ptr.get<ESM::Probe>()); it = ContainerStoreIterator(this, --probes.list.end()); break; - case Type_Repair: repairs.list.push_back (*ptr.get<ESM::Repair>()); it = ContainerStoreIterator(this, --repairs.list.end()); break; - case Type_Weapon: weapons.list.push_back (*ptr.get<ESM::Weapon>()); it = ContainerStoreIterator(this, --weapons.list.end()); break; + case Type_Potion: potions.mList.push_back (*ptr.get<ESM::Potion>()); it = ContainerStoreIterator(this, --potions.mList.end()); break; + case Type_Apparatus: appas.mList.push_back (*ptr.get<ESM::Apparatus>()); it = ContainerStoreIterator(this, --appas.mList.end()); break; + case Type_Armor: armors.mList.push_back (*ptr.get<ESM::Armor>()); it = ContainerStoreIterator(this, --armors.mList.end()); break; + case Type_Book: books.mList.push_back (*ptr.get<ESM::Book>()); it = ContainerStoreIterator(this, --books.mList.end()); break; + case Type_Clothing: clothes.mList.push_back (*ptr.get<ESM::Clothing>()); it = ContainerStoreIterator(this, --clothes.mList.end()); break; + case Type_Ingredient: ingreds.mList.push_back (*ptr.get<ESM::Ingredient>()); it = ContainerStoreIterator(this, --ingreds.mList.end()); break; + case Type_Light: lights.mList.push_back (*ptr.get<ESM::Light>()); it = ContainerStoreIterator(this, --lights.mList.end()); break; + case Type_Lockpick: lockpicks.mList.push_back (*ptr.get<ESM::Tool>()); it = ContainerStoreIterator(this, --lockpicks.mList.end()); break; + case Type_Miscellaneous: miscItems.mList.push_back (*ptr.get<ESM::Miscellaneous>()); it = ContainerStoreIterator(this, --miscItems.mList.end()); break; + case Type_Probe: probes.mList.push_back (*ptr.get<ESM::Probe>()); it = ContainerStoreIterator(this, --probes.mList.end()); break; + case Type_Repair: repairs.mList.push_back (*ptr.get<ESM::Repair>()); it = ContainerStoreIterator(this, --repairs.mList.end()); break; + case Type_Weapon: weapons.mList.push_back (*ptr.get<ESM::Weapon>()); it = ContainerStoreIterator(this, --weapons.mList.end()); break; } flagAsModified(); @@ -326,63 +326,63 @@ bool MWWorld::ContainerStoreIterator::resetIterator() { case ContainerStore::Type_Potion: - mPotion = mContainer->potions.list.begin(); - return mPotion!=mContainer->potions.list.end(); + mPotion = mContainer->potions.mList.begin(); + return mPotion!=mContainer->potions.mList.end(); case ContainerStore::Type_Apparatus: - mApparatus = mContainer->appas.list.begin(); - return mApparatus!=mContainer->appas.list.end(); + mApparatus = mContainer->appas.mList.begin(); + return mApparatus!=mContainer->appas.mList.end(); case ContainerStore::Type_Armor: - mArmor = mContainer->armors.list.begin(); - return mArmor!=mContainer->armors.list.end(); + mArmor = mContainer->armors.mList.begin(); + return mArmor!=mContainer->armors.mList.end(); case ContainerStore::Type_Book: - mBook = mContainer->books.list.begin(); - return mBook!=mContainer->books.list.end(); + mBook = mContainer->books.mList.begin(); + return mBook!=mContainer->books.mList.end(); case ContainerStore::Type_Clothing: - mClothing = mContainer->clothes.list.begin(); - return mClothing!=mContainer->clothes.list.end(); + mClothing = mContainer->clothes.mList.begin(); + return mClothing!=mContainer->clothes.mList.end(); case ContainerStore::Type_Ingredient: - mIngredient = mContainer->ingreds.list.begin(); - return mIngredient!=mContainer->ingreds.list.end(); + mIngredient = mContainer->ingreds.mList.begin(); + return mIngredient!=mContainer->ingreds.mList.end(); case ContainerStore::Type_Light: - mLight = mContainer->lights.list.begin(); - return mLight!=mContainer->lights.list.end(); + mLight = mContainer->lights.mList.begin(); + return mLight!=mContainer->lights.mList.end(); case ContainerStore::Type_Lockpick: - mLockpick = mContainer->lockpicks.list.begin(); - return mLockpick!=mContainer->lockpicks.list.end(); + mLockpick = mContainer->lockpicks.mList.begin(); + return mLockpick!=mContainer->lockpicks.mList.end(); case ContainerStore::Type_Miscellaneous: - mMiscellaneous = mContainer->miscItems.list.begin(); - return mMiscellaneous!=mContainer->miscItems.list.end(); + mMiscellaneous = mContainer->miscItems.mList.begin(); + return mMiscellaneous!=mContainer->miscItems.mList.end(); case ContainerStore::Type_Probe: - mProbe = mContainer->probes.list.begin(); - return mProbe!=mContainer->probes.list.end(); + mProbe = mContainer->probes.mList.begin(); + return mProbe!=mContainer->probes.mList.end(); case ContainerStore::Type_Repair: - mRepair = mContainer->repairs.list.begin(); - return mRepair!=mContainer->repairs.list.end(); + mRepair = mContainer->repairs.mList.begin(); + return mRepair!=mContainer->repairs.mList.end(); case ContainerStore::Type_Weapon: - mWeapon = mContainer->weapons.list.begin(); - return mWeapon!=mContainer->weapons.list.end(); + mWeapon = mContainer->weapons.mList.begin(); + return mWeapon!=mContainer->weapons.mList.end(); } return false; @@ -395,62 +395,62 @@ bool MWWorld::ContainerStoreIterator::incIterator() case ContainerStore::Type_Potion: ++mPotion; - return mPotion==mContainer->potions.list.end(); + return mPotion==mContainer->potions.mList.end(); case ContainerStore::Type_Apparatus: ++mApparatus; - return mApparatus==mContainer->appas.list.end(); + return mApparatus==mContainer->appas.mList.end(); case ContainerStore::Type_Armor: ++mArmor; - return mArmor==mContainer->armors.list.end(); + return mArmor==mContainer->armors.mList.end(); case ContainerStore::Type_Book: ++mBook; - return mBook==mContainer->books.list.end(); + return mBook==mContainer->books.mList.end(); case ContainerStore::Type_Clothing: ++mClothing; - return mClothing==mContainer->clothes.list.end(); + return mClothing==mContainer->clothes.mList.end(); case ContainerStore::Type_Ingredient: ++mIngredient; - return mIngredient==mContainer->ingreds.list.end(); + return mIngredient==mContainer->ingreds.mList.end(); case ContainerStore::Type_Light: ++mLight; - return mLight==mContainer->lights.list.end(); + return mLight==mContainer->lights.mList.end(); case ContainerStore::Type_Lockpick: ++mLockpick; - return mLockpick==mContainer->lockpicks.list.end(); + return mLockpick==mContainer->lockpicks.mList.end(); case ContainerStore::Type_Miscellaneous: ++mMiscellaneous; - return mMiscellaneous==mContainer->miscItems.list.end(); + return mMiscellaneous==mContainer->miscItems.mList.end(); case ContainerStore::Type_Probe: ++mProbe; - return mProbe==mContainer->probes.list.end(); + return mProbe==mContainer->probes.mList.end(); case ContainerStore::Type_Repair: ++mRepair; - return mRepair==mContainer->repairs.list.end(); + return mRepair==mContainer->repairs.mList.end(); case ContainerStore::Type_Weapon: ++mWeapon; - return mWeapon==mContainer->weapons.list.end(); + return mWeapon==mContainer->weapons.mList.end(); } return true; diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index d0d698feb6..1f11b62333 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -12,12 +12,12 @@ namespace MWWorld::CellRefList<T>& cellRefList, MWWorld::Ptr::CellStore *cell) { for (typename MWWorld::CellRefList<T>::List::iterator iter ( - cellRefList.list.begin()); - iter!=cellRefList.list.end(); ++iter) + cellRefList.mList.begin()); + iter!=cellRefList.mList.end(); ++iter) { - if (!iter->base->mScript.empty() && iter->mData.getCount()) + if (!iter->mBase->mScript.empty() && iter->mData.getCount()) { - localScripts.add (iter->base->mScript, MWWorld::Ptr (&*iter, cell)); + localScripts.add (iter->mBase->mScript, MWWorld::Ptr (&*iter, cell)); } } } @@ -73,23 +73,23 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) void MWWorld::LocalScripts::addCell (Ptr::CellStore *cell) { - listCellScripts (*this, cell->activators, cell); - listCellScripts (*this, cell->potions, cell); - listCellScripts (*this, cell->appas, cell); - listCellScripts (*this, cell->armors, cell); - listCellScripts (*this, cell->books, cell); - listCellScripts (*this, cell->clothes, cell); - listCellScripts (*this, cell->containers, cell); - listCellScripts (*this, cell->creatures, cell); - listCellScripts (*this, cell->doors, cell); - listCellScripts (*this, cell->ingreds, cell); - listCellScripts (*this, cell->lights, cell); - listCellScripts (*this, cell->lockpicks, cell); - listCellScripts (*this, cell->miscItems, cell); - listCellScripts (*this, cell->npcs, cell); - listCellScripts (*this, cell->probes, cell); - listCellScripts (*this, cell->repairs, cell); - listCellScripts (*this, cell->weapons, cell); + listCellScripts (*this, cell->mActivators, cell); + listCellScripts (*this, cell->mPotions, cell); + listCellScripts (*this, cell->mAppas, cell); + listCellScripts (*this, cell->mArmors, cell); + listCellScripts (*this, cell->mBooks, cell); + listCellScripts (*this, cell->mClothes, cell); + listCellScripts (*this, cell->mContainers, cell); + listCellScripts (*this, cell->mCreatures, cell); + listCellScripts (*this, cell->mDoors, cell); + listCellScripts (*this, cell->mIngreds, cell); + listCellScripts (*this, cell->mLights, cell); + listCellScripts (*this, cell->mLockpicks, cell); + listCellScripts (*this, cell->mMiscItems, cell); + listCellScripts (*this, cell->mNpcs, cell); + listCellScripts (*this, cell->mProbes, cell); + listCellScripts (*this, cell->mRepairs, cell); + listCellScripts (*this, cell->mWeapons, cell); } void MWWorld::LocalScripts::clear() diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index 6570761ab7..94e9dad150 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -25,7 +25,7 @@ namespace MWWorld if (const T *instance = list.search (name)) { LiveCellRef<T> ref; - ref.base = instance; + ref.mBase = instance; mRef = ref; mPtr = Ptr (&boost::any_cast<LiveCellRef<T>&> (mRef), 0); @@ -42,7 +42,7 @@ namespace MWWorld if (const T *instance = list.search (name)) { LiveCellRef<T> ref; - ref.base = instance; + ref.mBase = instance; mRef = ref; mPtr = Ptr (&boost::any_cast<LiveCellRef<T>&> (mRef), 0); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index e1eb02c32b..a436875ca7 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -17,8 +17,8 @@ namespace MWWorld mCellStore (0), mClass (0), mAutoMove (false), mForwardBackward (0) { - mPlayer.base = player; - mPlayer.ref.mRefID = "player"; + mPlayer.mBase = player; + mPlayer.mRef.mRefID = "player"; mName = player->mName; mMale = !(player->mFlags & ESM::NPC::Female); mRace = player->mRace; diff --git a/apps/openmw/mwworld/ptr.hpp b/apps/openmw/mwworld/ptr.hpp index f74fdd3ef7..594ddef2d5 100644 --- a/apps/openmw/mwworld/ptr.hpp +++ b/apps/openmw/mwworld/ptr.hpp @@ -50,7 +50,7 @@ namespace MWWorld : mContainerStore (0) { mPtr = liveCellRef; - mCellRef = &liveCellRef->ref; + mCellRef = &liveCellRef->mRef; mRefData = &liveCellRef->mData; mCell = cell; mTypeName = typeid (T).name(); diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 517025fb2f..ea62c0b3c3 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -20,15 +20,15 @@ namespace void insertCellRefList(MWRender::RenderingManager& rendering, T& cellRefList, MWWorld::CellStore &cell, MWWorld::PhysicsSystem& physics) { - if (!cellRefList.list.empty()) + if (!cellRefList.mList.empty()) { const MWWorld::Class& class_ = - MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.list.begin(), &cell)); + MWWorld::Class::get (MWWorld::Ptr (&*cellRefList.mList.begin(), &cell)); - int numRefs = cellRefList.list.size(); + int numRefs = cellRefList.mList.size(); int current = 0; - for (typename T::List::iterator it = cellRefList.list.begin(); - it != cellRefList.list.end(); it++) + for (typename T::List::iterator it = cellRefList.mList.begin(); + it != cellRefList.mList.end(); it++) { MWBase::Environment::get().getWindowManager ()->setLoadingProgress ("Loading cells", 1, current, numRefs); ++current; @@ -80,11 +80,15 @@ namespace MWWorld mPhysics->removeObject (node->getName()); } - if (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)) + if ((*iter)->mCell->isExterior()) { - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search((*iter)->cell->mData.mX,(*iter)->cell->mData.mY); + ESM::Land* land = + MWBase::Environment::get().getWorld()->getStore().lands.search( + (*iter)->mCell->getGridX(), + (*iter)->mCell->getGridY() + ); if (land) - mPhysics->removeHeightField( (*iter)->cell->mData.mX, (*iter)->cell->mData.mY ); + mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() ); } } @@ -111,13 +115,23 @@ namespace MWWorld float verts = ESM::Land::LAND_SIZE; float worldsize = ESM::Land::REAL_SIZE; - if (!(cell->cell->mData.mFlags & ESM::Cell::Interior)) + if (cell->mCell->isExterior()) { - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cell->cell->mData.mX,cell->cell->mData.mY); - if (land) - mPhysics->addHeightField (land->mLandData->mHeights, - cell->cell->mData.mX, cell->cell->mData.mY, - 0, ( worldsize/(verts-1) ), verts); + ESM::Land* land = + MWBase::Environment::get().getWorld()->getStore().lands.search( + cell->mCell->getGridX(), + cell->mCell->getGridY() + ); + if (land) { + mPhysics->addHeightField ( + land->mLandData->mHeights, + cell->mCell->getGridX(), + cell->mCell->getGridY(), + 0, + worldsize / (verts-1), + verts) + ; + } } mRendering.configureAmbient(*cell); @@ -128,8 +142,8 @@ namespace MWWorld void Scene::playerCellChange(MWWorld::CellStore *cell, const ESM::Position& pos, bool adjustPlayerPos) { - bool hasWater = cell->cell->mData.mFlags & cell->cell->HasWater; - mPhysics->setCurrentWater(hasWater, cell->cell->mWater); + bool hasWater = cell->mCell->mData.mFlags & ESM::Cell::HasWater; + mPhysics->setCurrentWater(hasWater, cell->mCell->mWater); MWBase::World *world = MWBase::Environment::get().getWorld(); world->getPlayer().setCell(cell); @@ -167,10 +181,10 @@ namespace MWWorld int numUnload = 0; while (active!=mActiveCells.end()) { - if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior)) + if ((*active)->mCell->isExterior()) { - if (std::abs (X-(*active)->cell->mData.mX)<=1 && - std::abs (Y-(*active)->cell->mData.mY)<=1) + if (std::abs (X-(*active)->mCell->getGridX())<=1 && + std::abs (Y-(*active)->mCell->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; @@ -185,10 +199,10 @@ namespace MWWorld active = mActiveCells.begin(); while (active!=mActiveCells.end()) { - if (!((*active)->cell->mData.mFlags & ESM::Cell::Interior)) + if ((*active)->mCell->isExterior()) { - if (std::abs (X-(*active)->cell->mData.mX)<=1 && - std::abs (Y-(*active)->cell->mData.mY)<=1) + if (std::abs (X-(*active)->mCell->getGridX())<=1 && + std::abs (Y-(*active)->mCell->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; @@ -210,10 +224,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); + assert ((*iter)->mCell->isExterior()); - if (x==(*iter)->cell->mData.mX && - y==(*iter)->cell->mData.mY) + if (x==(*iter)->mCell->getGridX() && + y==(*iter)->mCell->getGridY()) break; ++iter; @@ -232,10 +246,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); + assert ((*iter)->mCell->isExterior()); - if (x==(*iter)->cell->mData.mX && - y==(*iter)->cell->mData.mY) + if (x==(*iter)->mCell->getGridX() && + y==(*iter)->mCell->getGridY()) break; ++iter; @@ -256,10 +270,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert (!((*iter)->cell->mData.mFlags & ESM::Cell::Interior)); + assert ((*iter)->mCell->isExterior()); - if (X==(*iter)->cell->mData.mX && - Y==(*iter)->cell->mData.mY) + if (X==(*iter)->mCell->getGridX() && + Y==(*iter)->mCell->getGridY()) break; ++iter; @@ -376,26 +390,26 @@ namespace MWWorld void Scene::insertCell (Ptr::CellStore &cell) { // Loop through all references in the cell - insertCellRefList(mRendering, cell.activators, cell, *mPhysics); - insertCellRefList(mRendering, cell.potions, cell, *mPhysics); - insertCellRefList(mRendering, cell.appas, cell, *mPhysics); - insertCellRefList(mRendering, cell.armors, cell, *mPhysics); - insertCellRefList(mRendering, cell.books, cell, *mPhysics); - insertCellRefList(mRendering, cell.clothes, cell, *mPhysics); - insertCellRefList(mRendering, cell.containers, cell, *mPhysics); - insertCellRefList(mRendering, cell.creatures, cell, *mPhysics); - insertCellRefList(mRendering, cell.doors, cell, *mPhysics); - insertCellRefList(mRendering, cell.ingreds, cell, *mPhysics); - insertCellRefList(mRendering, cell.creatureLists, cell, *mPhysics); - insertCellRefList(mRendering, cell.itemLists, cell, *mPhysics); - insertCellRefList(mRendering, cell.lights, cell, *mPhysics); - insertCellRefList(mRendering, cell.lockpicks, cell, *mPhysics); - insertCellRefList(mRendering, cell.miscItems, cell, *mPhysics); - insertCellRefList(mRendering, cell.npcs, cell, *mPhysics); - insertCellRefList(mRendering, cell.probes, cell, *mPhysics); - insertCellRefList(mRendering, cell.repairs, cell, *mPhysics); - insertCellRefList(mRendering, cell.statics, cell, *mPhysics); - insertCellRefList(mRendering, cell.weapons, cell, *mPhysics); + insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics); + insertCellRefList(mRendering, cell.mPotions, cell, *mPhysics); + insertCellRefList(mRendering, cell.mAppas, cell, *mPhysics); + insertCellRefList(mRendering, cell.mArmors, cell, *mPhysics); + insertCellRefList(mRendering, cell.mBooks, cell, *mPhysics); + insertCellRefList(mRendering, cell.mClothes, cell, *mPhysics); + insertCellRefList(mRendering, cell.mContainers, cell, *mPhysics); + insertCellRefList(mRendering, cell.mCreatures, cell, *mPhysics); + insertCellRefList(mRendering, cell.mDoors, cell, *mPhysics); + insertCellRefList(mRendering, cell.mIngreds, cell, *mPhysics); + insertCellRefList(mRendering, cell.mCreatureLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.mItemLists, cell, *mPhysics); + insertCellRefList(mRendering, cell.mLights, cell, *mPhysics); + insertCellRefList(mRendering, cell.mLockpicks, cell, *mPhysics); + insertCellRefList(mRendering, cell.mMiscItems, cell, *mPhysics); + insertCellRefList(mRendering, cell.mNpcs, cell, *mPhysics); + insertCellRefList(mRendering, cell.mProbes, cell, *mPhysics); + insertCellRefList(mRendering, cell.mRepairs, cell, *mPhysics); + insertCellRefList(mRendering, cell.mStatics, cell, *mPhysics); + insertCellRefList(mRendering, cell.mWeapons, cell, *mPhysics); } void Scene::addObjectToScene (const Ptr& ptr) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 391b34a840..7d40e8ed4c 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -497,7 +497,7 @@ void WeatherManager::update(float duration) if (exterior) { - std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->cell->mRegion; + std::string regionstr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mRegion; boost::algorithm::to_lower(regionstr); if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c7f0de245e..1685798a25 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -25,10 +25,10 @@ namespace MWWorld::Ptr::CellStore *cell) { for (typename MWWorld::CellRefList<T>::List::iterator iter ( - cellRefList.list.begin()); - iter!=cellRefList.list.end(); ++iter) + cellRefList.mList.begin()); + iter!=cellRefList.mList.end(); ++iter) { - if (!iter->base->script.empty() && iter->mData.getCount()) + if (!iter->mBase->script.empty() && iter->mData.getCount()) { if (const ESM::Script *script = store.scripts.find (iter->base->script)) { @@ -46,7 +46,7 @@ namespace { typedef typename MWWorld::CellRefList<T>::List::iterator iterator; - for (iterator iter (refList.list.begin()); iter!=refList.list.end(); ++iter) + for (iterator iter (refList.mList.begin()); iter!=refList.mList.end(); ++iter) { if(iter->mData.getCount() > 0 && iter->mData.getBaseNode()){ if (iter->mData.getHandle()==handle) @@ -64,44 +64,44 @@ namespace MWWorld Ptr World::getPtrViaHandle (const std::string& handle, Ptr::CellStore& cell) { if (MWWorld::LiveCellRef<ESM::Activator> *ref = - searchViaHandle (handle, cell.activators)) + searchViaHandle (handle, cell.mActivators)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Potion> *ref = searchViaHandle (handle, cell.potions)) + if (MWWorld::LiveCellRef<ESM::Potion> *ref = searchViaHandle (handle, cell.mPotions)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = searchViaHandle (handle, cell.appas)) + if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = searchViaHandle (handle, cell.mAppas)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Armor> *ref = searchViaHandle (handle, cell.armors)) + if (MWWorld::LiveCellRef<ESM::Armor> *ref = searchViaHandle (handle, cell.mArmors)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Book> *ref = searchViaHandle (handle, cell.books)) + if (MWWorld::LiveCellRef<ESM::Book> *ref = searchViaHandle (handle, cell.mBooks)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Clothing> *ref = searchViaHandle (handle, cell.clothes)) + if (MWWorld::LiveCellRef<ESM::Clothing> *ref = searchViaHandle (handle, cell.mClothes)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Container> *ref = - searchViaHandle (handle, cell.containers)) + searchViaHandle (handle, cell.mContainers)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Creature> *ref = - searchViaHandle (handle, cell.creatures)) + searchViaHandle (handle, cell.mCreatures)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Door> *ref = searchViaHandle (handle, cell.doors)) + if (MWWorld::LiveCellRef<ESM::Door> *ref = searchViaHandle (handle, cell.mDoors)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = - searchViaHandle (handle, cell.ingreds)) + searchViaHandle (handle, cell.mIngreds)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Light> *ref = searchViaHandle (handle, cell.lights)) + if (MWWorld::LiveCellRef<ESM::Light> *ref = searchViaHandle (handle, cell.mLights)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Tool> *ref = searchViaHandle (handle, cell.lockpicks)) + if (MWWorld::LiveCellRef<ESM::Tool> *ref = searchViaHandle (handle, cell.mLockpicks)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = searchViaHandle (handle, cell.miscItems)) + if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = searchViaHandle (handle, cell.mMiscItems)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::NPC> *ref = searchViaHandle (handle, cell.npcs)) + if (MWWorld::LiveCellRef<ESM::NPC> *ref = searchViaHandle (handle, cell.mNpcs)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Probe> *ref = searchViaHandle (handle, cell.probes)) + if (MWWorld::LiveCellRef<ESM::Probe> *ref = searchViaHandle (handle, cell.mProbes)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Repair> *ref = searchViaHandle (handle, cell.repairs)) + if (MWWorld::LiveCellRef<ESM::Repair> *ref = searchViaHandle (handle, cell.mRepairs)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Static> *ref = searchViaHandle (handle, cell.statics)) + if (MWWorld::LiveCellRef<ESM::Static> *ref = searchViaHandle (handle, cell.mStatics)) return Ptr (ref, &cell); - if (MWWorld::LiveCellRef<ESM::Weapon> *ref = searchViaHandle (handle, cell.weapons)) + if (MWWorld::LiveCellRef<ESM::Weapon> *ref = searchViaHandle (handle, cell.mWeapons)) return Ptr (ref, &cell); return Ptr(); } @@ -585,10 +585,10 @@ namespace MWWorld if (*currCell != newCell) { if (isPlayer) { if (!newCell.isExterior()) { - changeToInteriorCell(toLower(newCell.cell->mName), pos); + changeToInteriorCell(toLower(newCell.mCell->mName), pos); } else { - int cellX = newCell.cell->mData.mX; - int cellY = newCell.cell->mData.mY; + int cellX = newCell.mCell->getGridX(); + int cellY = newCell.mCell->getGridY(); mWorldScene->changeCell(cellX, cellY, pos, false); } } else { @@ -1033,10 +1033,7 @@ namespace MWWorld Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->cell->mData.mFlags & ESM::Cell::Interior)) - return true; - else - return false; + return currentCell->mCell->isExterior(); } return false; } @@ -1046,7 +1043,7 @@ namespace MWWorld Ptr::CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->cell->mData.mFlags & ESM::Cell::QuasiEx)) + if (!(currentCell->mCell->mData.mFlags & ESM::Cell::QuasiEx)) return false; else return true; @@ -1071,7 +1068,7 @@ namespace MWWorld Ogre::Vector2 World::getNorthVector (CellStore* cell) { - MWWorld::CellRefList<ESM::Static>& statics = cell->statics; + MWWorld::CellRefList<ESM::Static>& statics = cell->mStatics; MWWorld::LiveCellRef<ESM::Static>* ref = statics.find("northmarker"); if (!ref) return Vector2(0, 1); @@ -1085,27 +1082,27 @@ namespace MWWorld { std::vector<World::DoorMarker> result; - MWWorld::CellRefList<ESM::Door>& doors = cell->doors; - std::list< MWWorld::LiveCellRef<ESM::Door> >& refList = doors.list; + MWWorld::CellRefList<ESM::Door>& doors = cell->mDoors; + std::list< MWWorld::LiveCellRef<ESM::Door> >& refList = doors.mList; for (std::list< MWWorld::LiveCellRef<ESM::Door> >::iterator it = refList.begin(); it != refList.end(); ++it) { MWWorld::LiveCellRef<ESM::Door>& ref = *it; - if (ref.ref.mTeleport) + if (ref.mRef.mTeleport) { World::DoorMarker newMarker; std::string dest; - if (ref.ref.mDestCell != "") + if (ref.mRef.mDestCell != "") { // door leads to an interior, use interior name - dest = ref.ref.mDestCell; + dest = ref.mRef.mDestCell; } else { // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; - positionToIndex (ref.ref.mDoorDest.pos[0], ref.ref.mDoorDest.pos[1], x, y); + positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y); const ESM::Cell* cell = mStore.cells.findExt(x,y); if (cell->mName != "") dest = cell->mName; @@ -1256,7 +1253,7 @@ namespace MWWorld /// \fixme should rely on object height pos.z += 30; - return isUnderwater(*object.getCell()->cell, pos); + return isUnderwater(*object.getCell()->mCell, pos); } bool @@ -1292,10 +1289,10 @@ namespace MWWorld mPhysics->castRay(playerPos, Ogre::Vector3(0,0,-1), 50); bool isOnGround = (hit.first ? (hit.second.distance (playerPos) < 25) : false); - if (!isOnGround || isUnderwater (*currentCell->cell, playerPos)) + if (!isOnGround || isUnderwater (*currentCell->mCell, playerPos)) return 2; - if (currentCell->cell->mData.mFlags & ESM::Cell::NoSleep) + if (currentCell->mCell->mData.mFlags & ESM::Cell::NoSleep) return 1; return 0; From f0a3ee0ef90b3fbd633c2f1c3dd8e69fca526f31 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 1 Oct 2012 17:15:16 +0400 Subject: [PATCH 110/255] gmst id should be lowercase, wipe RecIdListT --- components/esm/loadgmst.cpp | 32 ++++++++++-------- components/esm_store/reclists.hpp | 54 ------------------------------- components/esm_store/store.hpp | 2 +- 3 files changed, 19 insertions(+), 69 deletions(-) diff --git a/components/esm/loadgmst.cpp b/components/esm/loadgmst.cpp index dcc5001254..14e29f4ae8 100644 --- a/components/esm/loadgmst.cpp +++ b/components/esm/loadgmst.cpp @@ -2,6 +2,8 @@ #include <stdexcept> +#include <boost/algorithm/string.hpp> + #include "esmreader.hpp" #include "esmwriter.hpp" @@ -12,9 +14,9 @@ namespace ESM /// working properly in its current state and I doubt it can be fixed without breaking other stuff. // Some handy macros -#define cI(s,x) { if(mId == (s)) return (mI == (x)); } -#define cF(s,x) { if(mId == (s)) return (mF == (x)); } -#define cS(s,x) { if(mId == (s)) return (mStr == (x)); } +#define cI(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mI == (x)); } +#define cF(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mF == (x)); } +#define cS(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mStr == (x)); } bool GameSetting::isDirtyTribunal() { @@ -28,6 +30,7 @@ bool GameSetting::isDirtyTribunal() from other mods. */ + std::string label; // Strings cS("sProfitValue", "Profit Value"); // 'Profit:' cS("sEditNote", "Edit Note"); // same @@ -51,13 +54,14 @@ bool GameSetting::isDirtyTribunal() // [The difference here is "Profit Value" -> "Profit"] // Strings that matches the mId - cS("sEffectSummonFabricant", mId);// 'Summon Fabricant' + cS("sEffectSummonFabricant", "sEffectSummonFabricant");// 'Summon Fabricant' return false; } // Bloodmoon variant bool GameSetting::isDirtyBloodmoon() { + std::string label; // Strings cS("sWerewolfPopup", "Werewolf"); // same cS("sWerewolfRestMessage", @@ -69,16 +73,16 @@ bool GameSetting::isDirtyBloodmoon() // 'You have been detected as a known werewolf.' // Strings that matches the mId - cS("sMagicCreature01ID", mId); // 'BM_wolf_grey_summon' - cS("sMagicCreature02ID", mId); // 'BM_bear_black_summon' - cS("sMagicCreature03ID", mId); // 'BM_wolf_bone_summon' - cS("sMagicCreature04ID", mId); // same - cS("sMagicCreature05ID", mId); // same - cS("sEffectSummonCreature01", mId); // 'Calf Wolf' - cS("sEffectSummonCreature02", mId); // 'Calf Bear' - cS("sEffectSummonCreature03", mId); // 'Summon Bonewolf' - cS("sEffectSummonCreature04", mId); // same - cS("sEffectSummonCreature05", mId); // same + cS("sMagicCreature01ID", "sMagicCreature01ID"); // 'BM_wolf_grey_summon' + cS("sMagicCreature02ID", "sMagicCreature02ID"); // 'BM_bear_black_summon' + cS("sMagicCreature03ID", "sMagicCreature03ID"); // 'BM_wolf_bone_summon' + cS("sMagicCreature04ID", "sMagicCreature04ID"); // same + cS("sMagicCreature05ID", "sMagicCreature05ID"); // same + cS("sEffectSummonCreature01", "sEffectSummonCreature01"); // 'Calf Wolf' + cS("sEffectSummonCreature02", "sEffectSummonCreature02"); // 'Calf Bear' + cS("sEffectSummonCreature03", "sEffectSummonCreature03"); // 'Summon Bonewolf' + cS("sEffectSummonCreature04", "sEffectSummonCreature04"); // same + cS("sEffectSummonCreature05", "sEffectSummonCreature05"); // same // Integers cI("iWereWolfBounty", 10000); // 1000 diff --git a/components/esm_store/reclists.hpp b/components/esm_store/reclists.hpp index 0b265a5666..d9a7648054 100644 --- a/components/esm_store/reclists.hpp +++ b/components/esm_store/reclists.hpp @@ -209,60 +209,6 @@ namespace ESMS } }; - // The only difference to the above is a slight change to the load() - // function. We might merge these together later, and store the id - // in all the structs. - template <typename X> - struct RecIDListT : RecList - { - virtual ~RecIDListT() {} - - typedef std::map<std::string,X> MapType; - - MapType list; - - void load(ESMReader &esm, const std::string &id) - { - std::string id2 = toLower (id); - X& ref = list[id2]; - - ref.mId = id; - ref.load(esm); - } - - // Find the given object ID, or return NULL if not found. - const X* search(const std::string &id) const - { - std::string id2 = toLower (id); - - typename MapType::const_iterator iter = list.find (id2); - - if (iter == list.end()) - return NULL; - - return &iter->second; - } - - // Find the given object ID (throws an exception if not found) - const X* find(const std::string &id) const - { - const X *object = search (id); - - if (!object) - throw std::runtime_error ("object " + id + " not found"); - - return object; - } - - int getSize() { return list.size(); } - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) - identifier.push_back (iter->first); - } - }; - /* Land textures are indexed by an integer number */ struct LTexList : RecList diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp index 7329386d4a..db36afd330 100644 --- a/components/esm_store/store.hpp +++ b/components/esm_store/store.hpp @@ -68,7 +68,7 @@ namespace ESMS // Lists that need special rules CellList cells; - RecIDListT<GameSetting> gameSettings; + RecListWithIDT<GameSetting> gameSettings; LandList lands; LTexList landTexts; ScriptListT<Script> scripts; From 2057f5619e00fc604c420628dc57cdb97cabbe40 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 1 Oct 2012 19:17:04 +0400 Subject: [PATCH 111/255] move ESMStore to MWWorld --- apps/openmw/CMakeLists.txt | 1 + apps/openmw/mwbase/world.hpp | 8 +- apps/openmw/mwclass/door.cpp | 2 +- apps/openmw/mwclass/misc.cpp | 4 +- apps/openmw/mwclass/weapon.cpp | 2 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 19 ++- apps/openmw/mwdialogue/journalentry.cpp | 6 +- apps/openmw/mwdialogue/journalentry.hpp | 4 +- apps/openmw/mwdialogue/journalimp.cpp | 2 +- apps/openmw/mwdialogue/quest.cpp | 2 +- apps/openmw/mwdialogue/topic.cpp | 2 +- apps/openmw/mwgui/birth.cpp | 10 +- apps/openmw/mwgui/charactercreation.hpp | 2 +- apps/openmw/mwgui/class.cpp | 10 +- apps/openmw/mwgui/console.cpp | 9 +- apps/openmw/mwgui/container.hpp | 2 +- apps/openmw/mwgui/dialogue.cpp | 2 +- apps/openmw/mwgui/dialogue_history.cpp | 3 +- apps/openmw/mwgui/levelupdialog.cpp | 4 +- apps/openmw/mwgui/race.cpp | 12 +- apps/openmw/mwgui/race.hpp | 2 +- apps/openmw/mwgui/review.cpp | 4 +- apps/openmw/mwgui/spellwindow.cpp | 2 +- apps/openmw/mwgui/stats_window.cpp | 6 +- apps/openmw/mwgui/stats_window.hpp | 2 +- apps/openmw/mwgui/tooltips.cpp | 4 +- apps/openmw/mwgui/widgets.cpp | 13 +- apps/openmw/mwgui/widgets.hpp | 2 +- apps/openmw/mwmechanics/activespells.cpp | 2 +- apps/openmw/mwmechanics/actors.cpp | 4 +- apps/openmw/mwmechanics/creaturestats.cpp | 4 +- .../mwmechanics/mechanicsmanagerimp.cpp | 4 +- apps/openmw/mwmechanics/npcstats.cpp | 2 +- apps/openmw/mwmechanics/spells.cpp | 2 +- apps/openmw/mwmechanics/spellsuccess.hpp | 2 +- apps/openmw/mwrender/debugging.cpp | 2 +- apps/openmw/mwrender/globalmap.cpp | 7 +- apps/openmw/mwrender/localmap.cpp | 2 +- apps/openmw/mwrender/npcanimation.cpp | 6 +- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwrender/terrain.cpp | 2 +- apps/openmw/mwscript/cellextensions.cpp | 2 +- apps/openmw/mwscript/compilercontext.cpp | 2 +- apps/openmw/mwscript/globalscripts.cpp | 7 +- apps/openmw/mwscript/globalscripts.hpp | 6 +- apps/openmw/mwscript/guiextensions.cpp | 11 +- apps/openmw/mwscript/interpretercontext.cpp | 2 +- apps/openmw/mwscript/scriptmanagerimp.cpp | 6 +- apps/openmw/mwscript/scriptmanagerimp.hpp | 6 +- apps/openmw/mwscript/statsextensions.cpp | 2 +- .../mwscript/transformationextensions.cpp | 2 +- apps/openmw/mwsound/soundmanagerimp.cpp | 2 +- apps/openmw/mwworld/actioneat.cpp | 3 +- apps/openmw/mwworld/actionread.cpp | 7 +- apps/openmw/mwworld/cells.cpp | 9 +- apps/openmw/mwworld/cells.hpp | 11 +- apps/openmw/mwworld/cellstore.cpp | 11 +- apps/openmw/mwworld/cellstore.hpp | 14 +- apps/openmw/mwworld/containerstore.cpp | 2 +- apps/openmw/mwworld/containerstore.hpp | 2 +- .../openmw/mwworld/esmstore.cpp | 45 +++--- apps/openmw/mwworld/esmstore.hpp | 145 +++++++++++++++++ apps/openmw/mwworld/globals.cpp | 6 +- apps/openmw/mwworld/globals.hpp | 9 +- apps/openmw/mwworld/inventorystore.cpp | 3 +- apps/openmw/mwworld/localscripts.cpp | 6 +- apps/openmw/mwworld/localscripts.hpp | 10 +- apps/openmw/mwworld/manualref.hpp | 9 +- apps/openmw/mwworld/player.cpp | 2 +- .../openmw/mwworld}/reclists.hpp | 61 ++++---- apps/openmw/mwworld/scene.cpp | 2 +- apps/openmw/mwworld/weather.cpp | 3 +- apps/openmw/mwworld/worldimp.cpp | 10 +- apps/openmw/mwworld/worldimp.hpp | 7 +- components/CMakeLists.txt | 4 - components/esm_store/store.hpp | 146 ------------------ 76 files changed, 354 insertions(+), 403 deletions(-) rename components/esm_store/store.cpp => apps/openmw/mwworld/esmstore.cpp (65%) create mode 100644 apps/openmw/mwworld/esmstore.hpp rename {components/esm_store => apps/openmw/mwworld}/reclists.hpp (91%) delete mode 100644 components/esm_store/store.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 538f63dc96..07d27553de 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -53,6 +53,7 @@ add_openmw_dir (mwworld containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr actionopen actionread actionequip timestamp actionalchemy cellstore actionapply actioneat + esmstore reclists ) add_openmw_dir (mwclass diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index d29e23c18b..c1537e8ee1 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -31,11 +31,6 @@ namespace ESM struct Spell; } -namespace ESMS -{ - struct ESMStore; -} - namespace MWRender { class ExternalRendering; @@ -48,6 +43,7 @@ namespace MWWorld class LocalScripts; class Ptr; class TimeStamp; + class ESMStore; } namespace MWBase @@ -104,7 +100,7 @@ namespace MWBase virtual MWWorld::Player& getPlayer() = 0; - virtual const ESMS::ESMStore& getStore() const = 0; + virtual const MWWorld::ESMStore& getStore() const = 0; virtual ESM::ESMReader& getEsmReader() = 0; diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f944391e12..319c02e1e3 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -205,7 +205,7 @@ namespace MWClass std::string text; - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (ref->ref.mTeleport) { diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index edcfc7daa7..06c0200ac5 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -143,7 +143,7 @@ namespace MWClass MWGui::ToolTipInfo info; - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); int count = ptr.getRefData().getCount(); @@ -189,7 +189,7 @@ namespace MWClass { MWWorld::Ptr newPtr; - const ESMS::ESMStore &store = + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); if (MWWorld::Class::get(ptr).getName(ptr) == store.gameSettings.find("sGold")->getString()) { diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index fee0dfdf14..54705d91c4 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -277,7 +277,7 @@ namespace MWClass info.caption = ref->base->mName + MWGui::ToolTips::getCountString(ptr.getRefData().getCount()); info.icon = ref->base->mIcon; - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); std::string text; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 62f7df679b..8d2aefc865 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -7,8 +7,6 @@ #include <components/esm/loaddial.hpp> -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/scriptmanager.hpp" @@ -19,6 +17,7 @@ #include "../mwworld/refdata.hpp" #include "../mwworld/player.hpp" #include "../mwworld/containerstore.hpp" +#include "../mwworld/esmstore.hpp" #include "../mwgui/dialogue.hpp" @@ -84,7 +83,7 @@ namespace template<typename T> bool checkLocal (char comp, const std::string& name, T value, const MWWorld::Ptr& actor, - const ESMS::ESMStore& store) + const MWWorld::ESMStore& store) { std::string scriptName = MWWorld::Class::get (actor).getScript (actor); @@ -590,8 +589,8 @@ namespace MWDialogue mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); mActorKnownTopics.clear(); - ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + MWWorld::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; + for(MWWorld::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { mDialogueMap[toLower(it->first)] = it->second; } @@ -642,9 +641,9 @@ namespace MWDialogue //greeting bool greetingFound = false; - //ESMS::RecListT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + //MWWorld::RecListT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; + MWWorld::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; + for(MWWorld::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; if(ndialogue.mType == ESM::Dialogue::Greeting) @@ -742,8 +741,8 @@ namespace MWDialogue mChoice = -1; mActorKnownTopics.clear(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - ESMS::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - for(ESMS::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + MWWorld::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; + for(MWWorld::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) { ESM::Dialogue ndialogue = it->second; if(ndialogue.mType == ESM::Dialogue::Topic) diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index 1c6addb6eb..fb982d34fd 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -3,11 +3,11 @@ #include <stdexcept> -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwworld/esmstore.hpp" + namespace MWDialogue { JournalEntry::JournalEntry() {} @@ -16,7 +16,7 @@ namespace MWDialogue : mTopic (topic), mInfoId (infoId) {} - std::string JournalEntry::getText (const ESMS::ESMStore& store) const + std::string JournalEntry::getText (const MWWorld::ESMStore& store) const { const ESM::Dialogue *dialogue = store.dialogs.find (mTopic); diff --git a/apps/openmw/mwdialogue/journalentry.hpp b/apps/openmw/mwdialogue/journalentry.hpp index 3e86401852..19a9f42b5d 100644 --- a/apps/openmw/mwdialogue/journalentry.hpp +++ b/apps/openmw/mwdialogue/journalentry.hpp @@ -3,7 +3,7 @@ #include <string> -namespace ESMS +namespace MWWorld { struct ESMStore; } @@ -20,7 +20,7 @@ namespace MWDialogue JournalEntry (const std::string& topic, const std::string& infoId); - std::string getText (const ESMS::ESMStore& store) const; + std::string getText (const MWWorld::ESMStore& store) const; static JournalEntry makeFromQuest (const std::string& topic, int index); diff --git a/apps/openmw/mwdialogue/journalimp.cpp b/apps/openmw/mwdialogue/journalimp.cpp index ac4b7a6ded..2b2c603819 100644 --- a/apps/openmw/mwdialogue/journalimp.cpp +++ b/apps/openmw/mwdialogue/journalimp.cpp @@ -1,7 +1,7 @@ #include "journalimp.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index b4f02e1283..09feab8f98 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -1,7 +1,7 @@ #include "quest.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwdialogue/topic.cpp b/apps/openmw/mwdialogue/topic.cpp index 8c1dfafb8a..b6e7c07ae2 100644 --- a/apps/openmw/mwdialogue/topic.cpp +++ b/apps/openmw/mwdialogue/topic.cpp @@ -1,7 +1,7 @@ #include "topic.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" namespace MWDialogue { diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index e7862c4e7f..2ccf96bc41 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -3,7 +3,7 @@ #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> -#include "components/esm_store/store.hpp" +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -130,10 +130,10 @@ void BirthDialog::updateBirths() { mBirthList->removeAllItems(); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); - ESMS::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); + MWWorld::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); + MWWorld::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); int index = 0; // sort by name @@ -170,7 +170,7 @@ void BirthDialog::updateSpells() const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); std::string texturePath = std::string("textures\\") + birth->mTexture; diff --git a/apps/openmw/mwgui/charactercreation.hpp b/apps/openmw/mwgui/charactercreation.hpp index 28ced2e70a..9653aeede5 100644 --- a/apps/openmw/mwgui/charactercreation.hpp +++ b/apps/openmw/mwgui/charactercreation.hpp @@ -1,7 +1,7 @@ #ifndef CHARACTER_CREATION_HPP #define CHARACTER_CREATION_HPP -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index f020010ec5..40805c77e8 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -5,7 +5,7 @@ #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -185,10 +185,10 @@ void PickClassDialog::updateClasses() { mClassList->removeAllItems(); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - ESMS::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin(); - ESMS::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end(); + MWWorld::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin(); + MWWorld::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end(); int index = 0; for (; it != end; ++it) { @@ -209,7 +209,7 @@ void PickClassDialog::updateStats() { if (mCurrentClassId.empty()) return; - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Class *klass = store.classes.search(mCurrentClassId); if (!klass) return; diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index b939284dd8..589a7abac3 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -4,11 +4,10 @@ #include <algorithm> #include <fstream> -#include <components/esm_store/reclists.hpp> -#include <components/esm_store/store.hpp> - #include <components/compiler/exception.hpp> +#include "../mwworld/esmstore.hpp" + #include "../mwscript/extensions.hpp" #include "../mwbase/environment.hpp" @@ -93,9 +92,9 @@ namespace MWGui scanner.listKeywords (mNames); // identifier - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - for (ESMS::RecListList::const_iterator iter (store.recLists.begin()); + for (MWWorld::RecListList::const_iterator iter (store.recLists.begin()); iter!=store.recLists.end(); ++iter) { iter->second->listIdentifier (mNames); diff --git a/apps/openmw/mwgui/container.hpp b/apps/openmw/mwgui/container.hpp index 27c3288ae7..08d425032f 100644 --- a/apps/openmw/mwgui/container.hpp +++ b/apps/openmw/mwgui/container.hpp @@ -1,7 +1,7 @@ #ifndef MGUI_CONTAINER_H #define MGUI_CONTAINER_H -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "window_base.hpp" #include "referenceinterface.hpp" diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 96b85b4c4c..66444e18c6 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -6,7 +6,7 @@ #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/dialoguemanager.hpp" diff --git a/apps/openmw/mwgui/dialogue_history.cpp b/apps/openmw/mwgui/dialogue_history.cpp index 4ca764c82b..13f72545e2 100644 --- a/apps/openmw/mwgui/dialogue_history.cpp +++ b/apps/openmw/mwgui/dialogue_history.cpp @@ -3,7 +3,8 @@ #include "../mwbase/windowmanager.hpp" #include "widgets.hpp" -#include "components/esm_store/store.hpp" + +#include "../mwworld/esmstore.hpp" #include <iostream> #include <iterator> diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 7dced94f50..afb4bb6214 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -8,14 +8,12 @@ #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" +#include "../mwworld/esmstore.hpp" #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/stat.hpp" -#include <components/esm_store/reclists.hpp> -#include <components/esm_store/store.hpp> - namespace MWGui { diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index d681bc69dc..72feb84a4b 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -6,7 +6,7 @@ #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -224,10 +224,10 @@ void RaceDialog::updateRaces() { mRaceList->removeAllItems(); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - ESMS::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin(); - ESMS::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end(); + MWWorld::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin(); + MWWorld::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end(); int index = 0; for (; it != end; ++it) { @@ -258,7 +258,7 @@ void RaceDialog::updateSkills() const int lineHeight = 18; MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Race *race = store.races.find(mCurrentRaceId); int count = sizeof(race->mData.mBonus)/sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) @@ -296,7 +296,7 @@ void RaceDialog::updateSpellPowers() const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Race *race = store.races.find(mCurrentRaceId); std::vector<std::string>::const_iterator it = race->mPowers.mList.begin(); diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index c4734eae8c..000b845231 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -4,7 +4,7 @@ #include <boost/array.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwrender/characterpreview.hpp" diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 984c7d1aea..961856b7ca 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -5,7 +5,7 @@ #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -281,7 +281,7 @@ void ReviewDialog::addSkills(const SkillList &skills, const std::string &titleId if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes continue; assert(skillId >= 0 && skillId < ESM::Skill::Length); - const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; + const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second; float base = stat.getBase(); float modified = stat.getModified(); diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index a203ac92b7..c7f61a935b 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -4,7 +4,7 @@ #include <boost/lexical_cast.hpp> #include <boost/format.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 665caaae1a..ccba9cf747 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -54,7 +54,7 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager) { 0, 0 } }; - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); for (int i=0; names[i][0]; ++i) { setText (names[i][0], store.gameSettings.find (names[i][1])->getString()); @@ -357,7 +357,7 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, if (skillId < 0 || skillId > ESM::Skill::Length) // Skip unknown skill indexes continue; assert(skillId >= 0 && skillId < ESM::Skill::Length); - const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; + const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; const MWMechanics::Stat<float> &stat = mSkillValues.find(skillId)->second; float base = stat.getBase(); float modified = stat.getModified(); @@ -422,7 +422,7 @@ void StatsWindow::updateSkillArea() if (!mMiscSkills.empty()) addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); // race tooltip const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); diff --git a/apps/openmw/mwgui/stats_window.hpp b/apps/openmw/mwgui/stats_window.hpp index 75f8c568bf..5186b63285 100644 --- a/apps/openmw/mwgui/stats_window.hpp +++ b/apps/openmw/mwgui/stats_window.hpp @@ -1,7 +1,7 @@ #ifndef MWGUI_STATS_WINDOW_H #define MWGUI_STATS_WINDOW_H -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <sstream> #include <set> diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 35224613ce..d47a0f547f 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -365,7 +365,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) text.erase(0, 1); const ESM::Enchantment* enchant = 0; - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (info.enchant != "") { enchant = store.enchants.search(info.enchant); @@ -571,7 +571,7 @@ void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId) if (skillId == -1) return; - const std::string &skillNameId = ESMS::Skill::sSkillNameIds[skillId]; + const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); assert(skill); const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index ed09b98058..5050ba88ad 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -2,12 +2,12 @@ #include <boost/lexical_cast.hpp> -#include "components/esm_store/store.hpp" - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwworld/esmstore.hpp" + #undef min #undef max @@ -228,7 +228,7 @@ void MWSpell::setSpellId(const std::string &spellId) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) { - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Spell *spell = store.spells.search(mId); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); @@ -259,7 +259,7 @@ void MWSpell::updateWidgets() { if (mSpellNameWidget && mWindowManager) { - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Spell *spell = store.spells.search(mId); if (spell) static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->mName); @@ -386,7 +386,10 @@ void MWSpellEffect::setSpellEffect(const SpellEffectParams& params) void MWSpellEffect::updateWidgets() { - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + if (!mWindowManager) + return; + + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); assert(magicEffect); diff --git a/apps/openmw/mwgui/widgets.hpp b/apps/openmw/mwgui/widgets.hpp index a41e1f1238..4ac5383f7a 100644 --- a/apps/openmw/mwgui/widgets.hpp +++ b/apps/openmw/mwgui/widgets.hpp @@ -1,7 +1,7 @@ #ifndef MWGUI_WIDGETS_H #define MWGUI_WIDGETS_H -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <MyGUI.h> diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index df5ea7c3ff..7deab426d4 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -9,7 +9,7 @@ #include <components/esm/loadmgef.hpp> #include <components/esm/loadskil.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index f3b6b16162..b5933a646f 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -7,7 +7,7 @@ #include <components/esm/loadnpc.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwworld/class.hpp" #include "../mwworld/inventorystore.hpp" @@ -101,7 +101,7 @@ namespace MWMechanics health.setCurrent (health.getCurrent() + 0.1 * endurance); stats.setHealth (health); - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); float fFatigueReturnBase = store.gameSettings.find("fFatigueReturnBase")->getFloat (); float fFatigueReturnMult = store.gameSettings.find("fFatigueReturnMult")->getFloat (); diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 1e57ba3136..9a6a5c0f20 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -2,7 +2,7 @@ #include <algorithm> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -41,7 +41,7 @@ namespace MWMechanics float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max); - const ESMS::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); return store.gameSettings.find ("fFatigueBase")->getFloat() - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 873dd94988..81e3ae5407 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1,7 +1,7 @@ #include "mechanicsmanagerimp.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -132,7 +132,7 @@ namespace MWMechanics } } - typedef ESMS::IndexListT<ESM::Skill>::MapType ContainerType; + typedef MWWorld::IndexListT<ESM::Skill>::MapType ContainerType; const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list; for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index bbd42c1471..e01f7cc1cb 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -10,7 +10,7 @@ #include <components/esm/loadclas.hpp> #include <components/esm/loadgmst.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index adfb35cd96..b883abaf07 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -1,7 +1,7 @@ #include "spells.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/esm/loadspel.hpp> diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index a46667cdc4..9928966bb9 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -8,7 +8,7 @@ #include "../mwworld/class.hpp" #include "../mwmechanics/creaturestats.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "npcstats.hpp" diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index 4f71507545..d1f6162836 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -11,7 +11,7 @@ #include <components/esm/loadstat.hpp> #include <components/esm/loadpgrd.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone #include "../mwbase/environment.hpp" diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 7a799a2e43..e8ddecb3d2 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -11,8 +11,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" -#include <components/esm_store/store.hpp> -#include <components/esm_store/reclists.hpp> +#include "../mwworld/esmstore.hpp" namespace MWRender { @@ -30,8 +29,8 @@ namespace MWRender Ogre::TexturePtr tex; // get the size of the world - const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; - for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + const MWWorld::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; + for (MWWorld::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) { if (it->first.first < mMinX) mMinX = it->first.first; diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 1bdbce6d97..82bd3ae018 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -4,7 +4,7 @@ #include <OgreMaterialManager.h> #include <OgreHardwarePixelBuffer.h> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 5c2b05acab..8282751f40 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -4,7 +4,7 @@ #include <OgreEntity.h> #include <OgreSubEntity.h> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -62,7 +62,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor mPartPriorities[init] = 0; } - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Race *race = store.races.find(ref->base->mRace); std::string hairID = ref->base->mHair; @@ -322,7 +322,7 @@ void NpcAnimation::updateParts() { ESM::PRT_Tail, { "tail", "" } } }; - const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); for(size_t i = 0;i < sizeof(PartTypeList)/sizeof(PartTypeList[0]);i++) { if(mPartPriorities[PartTypeList[i].type] < 1) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 5b5fdce68e..fa6bd3cc71 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -18,7 +18,7 @@ #include <extern/shiny/Platforms/Ogre/OgrePlatform.hpp> #include <components/esm/loadstat.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/settings/settings.hpp> #include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index 114a9bc375..d4a62a62aa 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -4,7 +4,7 @@ #include <OgreTerrainGroup.h> #include <OgreHardwarePixelBuffer.h> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/settings/settings.hpp> diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 57dd7962b2..61c28f3234 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -1,7 +1,7 @@ #include "cellextensions.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/compiler/extensions.hpp> diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 139a5cc6cf..8756fb6330 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -1,7 +1,7 @@ #include "compilercontext.hpp" -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/compiler/locals.hpp> diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 37cf341271..5cd769da77 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -3,8 +3,7 @@ #include <cassert> -#include <components/esm_store/reclists.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/scriptmanager.hpp" @@ -13,12 +12,12 @@ namespace MWScript { - GlobalScripts::GlobalScripts (const ESMS::ESMStore& store) + GlobalScripts::GlobalScripts (const MWWorld::ESMStore& store) : mStore (store) { addScript ("Main"); - for (ESMS::RecListT<ESM::StartScript>::MapType::const_iterator iter + for (MWWorld::RecListT<ESM::StartScript>::MapType::const_iterator iter (store.startScripts.list.begin()); iter != store.startScripts.list.end(); ++iter) addScript (iter->second.mScript); diff --git a/apps/openmw/mwscript/globalscripts.hpp b/apps/openmw/mwscript/globalscripts.hpp index cc2f7ffdd4..f9f9b7ae3a 100644 --- a/apps/openmw/mwscript/globalscripts.hpp +++ b/apps/openmw/mwscript/globalscripts.hpp @@ -6,7 +6,7 @@ #include "locals.hpp" -namespace ESMS +namespace MWWorld { struct ESMStore; } @@ -15,12 +15,12 @@ namespace MWScript { class GlobalScripts { - const ESMS::ESMStore& mStore; + const MWWorld::ESMStore& mStore; std::map<std::string, std::pair<bool, Locals> > mScripts; // running, local variables public: - GlobalScripts (const ESMS::ESMStore& store); + GlobalScripts (const MWWorld::ESMStore& store); void addScript (const std::string& name); diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 66bb4e0432..1eaac5d5f9 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -9,8 +9,7 @@ #include <components/interpreter/runtime.hpp> #include <components/interpreter/opcodes.hpp> -#include <components/esm_store/store.hpp> -#include <components/esm_store/reclists.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/windowmanager.hpp" @@ -109,8 +108,8 @@ namespace MWScript // "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's House as well." // http://www.uesp.net/wiki/Tes3Mod:ShowMap - const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; - for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + const MWWorld::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; + for (MWWorld::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) { std::string name = it->second->mName; boost::algorithm::to_lower(name); @@ -126,8 +125,8 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - const ESMS::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; - for (ESMS::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + const MWWorld::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; + for (MWWorld::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) { std::string name = it->second->mName; if (name != "") diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index 075ac56462..d5159eb7da 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -5,7 +5,7 @@ #include <stdexcept> #include <components/interpreter/types.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 883d3dfd38..1f4e80382a 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -7,7 +7,7 @@ #include <exception> #include <components/esm/loadscpt.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/compiler/scanner.hpp> #include <components/compiler/context.hpp> @@ -17,7 +17,7 @@ namespace MWScript { - ScriptManager::ScriptManager (const ESMS::ESMStore& store, bool verbose, + ScriptManager::ScriptManager (const MWWorld::ESMStore& store, bool verbose, Compiler::Context& compilerContext) : mErrorHandler (std::cerr), mStore (store), mVerbose (verbose), mCompilerContext (compilerContext), mParser (mErrorHandler, mCompilerContext), @@ -125,7 +125,7 @@ namespace MWScript std::pair<int, int> ScriptManager::compileAll() { - typedef ESMS::ScriptListT<ESM::Script>::MapType Container; + typedef MWWorld::ScriptListT<ESM::Script>::MapType Container; const Container& scripts = mStore.scripts.list; diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index a97310ae5c..c4a016eb79 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -14,7 +14,7 @@ #include "globalscripts.hpp" -namespace ESMS +namespace MWWorld { struct ESMStore; } @@ -35,7 +35,7 @@ namespace MWScript class ScriptManager : public MWBase::ScriptManager { Compiler::StreamErrorHandler mErrorHandler; - const ESMS::ESMStore& mStore; + const MWWorld::ESMStore& mStore; bool mVerbose; Compiler::Context& mCompilerContext; Compiler::FileParser mParser; @@ -50,7 +50,7 @@ namespace MWScript public: - ScriptManager (const ESMS::ESMStore& store, bool verbose, + ScriptManager (const MWWorld::ESMStore& store, bool verbose, Compiler::Context& compilerContext); virtual void run (const std::string& name, Interpreter::Context& interpreterContext); diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 0d69608e1c..a4634eb219 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -7,7 +7,7 @@ #include <components/esm/loadnpc.hpp> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/compiler/extensions.hpp> diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 6e70f588e0..a64651a977 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -3,7 +3,7 @@ #include <OgreMath.h> #include <OgreSceneNode.h> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include <components/esm/loadcell.hpp> #include <components/compiler/extensions.hpp> diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 5d5ef3d1d0..62814a38ce 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -4,7 +4,7 @@ #include <algorithm> #include <map> -#include <components/esm_store/store.hpp> +#include "../mwworld/esmstore.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" diff --git a/apps/openmw/mwworld/actioneat.cpp b/apps/openmw/mwworld/actioneat.cpp index abd1ac4b97..63efff738e 100644 --- a/apps/openmw/mwworld/actioneat.cpp +++ b/apps/openmw/mwworld/actioneat.cpp @@ -5,14 +5,13 @@ #include <components/esm/loadskil.hpp> -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/npcstats.hpp" +#include "esmstore.hpp" #include "class.hpp" namespace MWWorld diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 4ac613df7f..4333183e3f 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -4,15 +4,14 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" -#include "../mwworld/player.hpp" -#include "../mwworld/class.hpp" - #include "../mwmechanics/npcstats.hpp" #include "../mwgui/bookwindow.hpp" #include "../mwgui/scrollwindow.hpp" -#include <components/esm_store/store.hpp> +#include "player.hpp" +#include "class.hpp" +#include "esmstore.hpp" namespace MWWorld { diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index e5a38d4be1..4a94a5797f 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -1,11 +1,10 @@ #include "cells.hpp" -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "class.hpp" +#include "esmstore.hpp" #include "containerstore.hpp" MWWorld::Ptr::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) @@ -85,7 +84,7 @@ MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, Ptr::CellS return ptr; } -MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader) +MWWorld::Cells::Cells (const MWWorld::ESMStore& store, ESM::ESMReader& reader) : mStore (store), mReader (reader), mIdCache (20, std::pair<std::string, Ptr::CellStore *> ("", (Ptr::CellStore*)0)), /// \todo make cache size configurable mIdCacheIndex (0) @@ -265,7 +264,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) } // Now try the other cells - for (ESMS::CellList::IntCells::const_iterator iter = mStore.cells.intCells.begin(); + for (MWWorld::CellList::IntCells::const_iterator iter = mStore.cells.intCells.begin(); iter!=mStore.cells.intCells.end(); ++iter) { Ptr::CellStore *cellStore = getCellStore (iter->second); @@ -276,7 +275,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) return ptr; } - for (ESMS::CellList::ExtCells::const_iterator iter = mStore.cells.extCells.begin(); + for (MWWorld::CellList::ExtCells::const_iterator iter = mStore.cells.extCells.begin(); iter!=mStore.cells.extCells.end(); ++iter) { Ptr::CellStore *cellStore = getCellStore (iter->second); diff --git a/apps/openmw/mwworld/cells.hpp b/apps/openmw/mwworld/cells.hpp index 3e13831665..edaf700552 100644 --- a/apps/openmw/mwworld/cells.hpp +++ b/apps/openmw/mwworld/cells.hpp @@ -11,17 +11,14 @@ namespace ESM class ESMReader; } -namespace ESM -{ - class ESMStore; -} - namespace MWWorld { + class ESMStore; + /// \brief Cell container class Cells { - const ESMS::ESMStore& mStore; + const MWWorld::ESMStore& mStore; ESM::ESMReader& mReader; std::map<std::string, CellStore> mInteriors; std::map<std::pair<int, int>, CellStore> mExteriors; @@ -39,7 +36,7 @@ namespace MWWorld public: - Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader); + Cells (const MWWorld::ESMStore& store, ESM::ESMReader& reader); ///< \todo pass the dynamic part of the ESMStore isntead (once it is written) of the whole /// world diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index fcdec1e7f0..4a84e33a78 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -2,12 +2,11 @@ #include <iostream> -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "ptr.hpp" +#include "esmstore.hpp" namespace MWWorld { @@ -16,7 +15,7 @@ namespace MWWorld mWaterLevel = cell->mWater; } - void CellStore::load (const ESMS::ESMStore &store, ESM::ESMReader &esm) + void CellStore::load (const MWWorld::ESMStore &store, ESM::ESMReader &esm) { if (mState!=State_Loaded) { @@ -31,7 +30,7 @@ namespace MWWorld } } - void CellStore::preload (const ESMS::ESMStore &store, ESM::ESMReader &esm) + void CellStore::preload (const MWWorld::ESMStore &store, ESM::ESMReader &esm) { if (mState==State_Unloaded) { @@ -41,7 +40,7 @@ namespace MWWorld } } - void CellStore::listRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) + void CellStore::listRefs(const MWWorld::ESMStore &store, ESM::ESMReader &esm) { assert (cell); @@ -67,7 +66,7 @@ namespace MWWorld std::sort (mIds.begin(), mIds.end()); } - void CellStore::loadRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm) + void CellStore::loadRefs(const MWWorld::ESMStore &store, ESM::ESMReader &esm) { assert (cell); diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 32ab6e07b9..ccdbcf280e 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -8,14 +8,10 @@ #include "refdata.hpp" -namespace ESMS -{ - struct ESMStore; -} - namespace MWWorld { class Ptr; + class ESMStore; /// A reference to one object (of any type) in a cell. /// @@ -122,9 +118,9 @@ namespace MWWorld CellRefList<ESM::Static> statics; CellRefList<ESM::Weapon> weapons; - void load (const ESMS::ESMStore &store, ESM::ESMReader &esm); + void load (const MWWorld::ESMStore &store, ESM::ESMReader &esm); - void preload (const ESMS::ESMStore &store, ESM::ESMReader &esm); + void preload (const MWWorld::ESMStore &store, ESM::ESMReader &esm); /// Call functor (ref) for each reference. functor must return a bool. Returning /// false will abort the iteration. @@ -183,9 +179,9 @@ namespace MWWorld } /// Run through references and store IDs - void listRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm); + void listRefs(const MWWorld::ESMStore &store, ESM::ESMReader &esm); - void loadRefs(const ESMS::ESMStore &store, ESM::ESMReader &esm); + void loadRefs(const MWWorld::ESMStore &store, ESM::ESMReader &esm); }; } diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 5c4dd03a45..e3dd493809 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -145,7 +145,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::addImpl (const Ptr& ptr return it; } -void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const ESMS::ESMStore& store) +void MWWorld::ContainerStore::fill (const ESM::InventoryList& items, const MWWorld::ESMStore& store) { for (std::vector<ESM::ContItem>::const_iterator iter (items.mList.begin()); iter!=items.mList.end(); ++iter) diff --git a/apps/openmw/mwworld/containerstore.hpp b/apps/openmw/mwworld/containerstore.hpp index ae27fad3d3..1297fc53c6 100644 --- a/apps/openmw/mwworld/containerstore.hpp +++ b/apps/openmw/mwworld/containerstore.hpp @@ -83,7 +83,7 @@ namespace MWWorld public: - void fill (const ESM::InventoryList& items, const ESMS::ESMStore& store); + void fill (const ESM::InventoryList& items, const MWWorld::ESMStore& store); ///< Insert items into *this. void clear(); diff --git a/components/esm_store/store.cpp b/apps/openmw/mwworld/esmstore.cpp similarity index 65% rename from components/esm_store/store.cpp rename to apps/openmw/mwworld/esmstore.cpp index d1fe9b10be..c145fb3da1 100644 --- a/components/esm_store/store.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -1,31 +1,21 @@ +#include "esmstore.hpp" + #include <set> #include <iostream> -#include "store.hpp" -using namespace std; -using namespace ESM; -using namespace ESMS; - -/* -static string toStr(int i) +namespace MWWorld { - char name[5]; - *((int*)name) = i; - name[4] = 0; - return std::string(name); -} -*/ -void ESMStore::load(ESMReader &esm) +void ESMStore::load(ESM::ESMReader &esm) { - set<string> missing; + std::set<std::string> missing; ESM::Dialogue *dialogue = 0; // Loop through all records while(esm.hasMoreRecs()) { - NAME n = esm.getRecName(); + ESM::NAME n = esm.getRecName(); esm.getRecHeader(); // Look up the record type. @@ -71,7 +61,8 @@ void ESMStore::load(ESMReader &esm) if (n.val==ESM::REC_DIAL) { - RecListCaseT<Dialogue>& recList = static_cast<RecListCaseT<Dialogue>& > (*it->second); + RecListCaseT<ESM::Dialogue>& recList = + static_cast<RecListCaseT<ESM::Dialogue>& > (*it->second); ESM::Dialogue* d = recList.search (id); @@ -84,20 +75,22 @@ void ESMStore::load(ESMReader &esm) // Insert the reference into the global lookup if(!id.empty() && - (n.val==REC_ACTI || n.val==REC_ALCH || n.val==REC_APPA || n.val==REC_ARMO || - n.val==REC_BOOK || n.val==REC_CLOT || n.val==REC_CONT || n.val==REC_CREA || - n.val==REC_DOOR || n.val==REC_INGR || n.val==REC_LEVC || n.val==REC_LEVI || - n.val==REC_LIGH || n.val==REC_LOCK || n.val==REC_MISC || n.val==REC_NPC_ || - n.val==REC_PROB || n.val==REC_REPA || n.val==REC_STAT || n.val==REC_WEAP) + (n.val==ESM::REC_ACTI || n.val==ESM::REC_ALCH || n.val==ESM::REC_APPA || n.val==ESM::REC_ARMO || + n.val==ESM::REC_BOOK || n.val==ESM::REC_CLOT || n.val==ESM::REC_CONT || n.val==ESM::REC_CREA || + n.val==ESM::REC_DOOR || n.val==ESM::REC_INGR || n.val==ESM::REC_LEVC || n.val==ESM::REC_LEVI || + n.val==ESM::REC_LIGH || n.val==ESM::REC_LOCK || n.val==ESM::REC_MISC || n.val==ESM::REC_NPC_ || + n.val==ESM::REC_PROB || n.val==ESM::REC_REPA || n.val==ESM::REC_STAT || n.val==ESM::REC_WEAP) ) all[id] = n.val; } } - for (int i = 0; i < Attribute::Length; ++i) + for (int i = 0; i < ESM::Attribute::Length; ++i) { - Attribute::AttributeID id = Attribute::sAttributeIds[i]; - attributes.list.insert(std::make_pair(id, Attribute(id, Attribute::sGmstAttributeIds[i], Attribute::sGmstAttributeDescIds[i]))); + typedef ESM::Attribute EsmAttr; + + EsmAttr::AttributeID id = EsmAttr::sAttributeIds[i]; + attributes.list.insert(std::make_pair(id, ESM::Attribute(id, EsmAttr::sGmstAttributeIds[i], EsmAttr::sGmstAttributeDescIds[i]))); } /* This information isn't needed on screen. But keep the code around @@ -113,3 +106,5 @@ void ESMStore::load(ESMReader &esm) cout << endl; */ } + +} // end namespace diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp new file mode 100644 index 0000000000..226b758dc6 --- /dev/null +++ b/apps/openmw/mwworld/esmstore.hpp @@ -0,0 +1,145 @@ +#ifndef OPENMW_MWWORLD_STORE_H +#define OPENMW_MWWORLD_STORE_H + +/* + The ESM storage module. + + This is separate from the ESM loader module, located in esm/. It is + also unaware of the cell loading and storage module. + + The advantage of this, as with all other modularizations, is that + you can replace the storage method later without touching the + loading code. Cutting down dependencies also help on the general + maintainability. + */ + +#include <components/esm/records.hpp> +#include "reclists.hpp" + +namespace MWWorld +{ + + struct ESMStore + { + /* Lists all the list types. Mostly used for quick lookup on + loading. The key is the record name (4 chars) parsed as a 32 + bit int. See esm/records.hpp for the complete list. + */ + RecListList recLists; + + // Each individual list + RecListT<ESM::Activator> activators; + RecListWithIDT<ESM::Potion> potions; + RecListT<ESM::Apparatus> appas; + RecListT<ESM::Armor> armors; + RecListT<ESM::BodyPart> bodyParts; + RecListWithIDT<ESM::Book> books; + RecListT<ESM::BirthSign> birthSigns; + RecListT<ESM::Class> classes; + RecListT<ESM::Clothing> clothes; + RecListT<ESM::LoadCNTC> contChange; + RecListT<ESM::Container> containers; + RecListWithIDT<ESM::Creature> creatures; + RecListT<ESM::LoadCREC> creaChange; + RecListCaseT<ESM::Dialogue> dialogs; + RecListT<ESM::Door> doors; + RecListT<ESM::Enchantment> enchants; + RecListT<ESM::Faction> factions; + RecListT<ESM::Global> globals; + RecListWithIDT<ESM::Ingredient> ingreds; + RecListT<ESM::CreatureLevList> creatureLists; + RecListT<ESM::ItemLevList> itemLists; + RecListT<ESM::Light> lights; + RecListT<ESM::Tool> lockpicks; + RecListT<ESM::Miscellaneous> miscItems; + RecListWithIDT<ESM::NPC> npcs; + RecListT<ESM::LoadNPCC> npcChange; + RecListT<ESM::Probe> probes; + RecListT<ESM::Race> races; + RecListT<ESM::Region> regions; + RecListT<ESM::Repair> repairs; + RecListT<ESM::SoundGenerator> soundGens; + RecListT<ESM::Sound> sounds; + RecListT<ESM::Spell> spells; + RecListT<ESM::StartScript> startScripts; + RecListT<ESM::Static> statics; + RecListT<ESM::Weapon> weapons; + + // Lists that need special rules + CellList cells; + RecListWithIDT<ESM::GameSetting> gameSettings; + LandList lands; + LTexList landTexts; + ScriptListT<ESM::Script> scripts; + IndexListT<ESM::MagicEffect> magicEffects; + IndexListT<ESM::Skill> skills; + //RecListT<ESM::Pathgrid> pathgrids; + PathgridList pathgrids; + + // Special entry which is hardcoded and not loaded from an ESM + IndexListT<ESM::Attribute> attributes; + + // Lookup of all IDs. Makes looking up references faster. Just + // maps the id name to the record type. + typedef std::map<std::string, int> AllMap; + AllMap all; + + // Look up the given ID in 'all'. Returns 0 if not found. + int find(const std::string &id) const + { + AllMap::const_iterator it = all.find(id); + if(it == all.end()) return 0; + return it->second; + } + + ESMStore() + { + recLists[ESM::REC_ACTI] = &activators; + recLists[ESM::REC_ALCH] = &potions; + recLists[ESM::REC_APPA] = &appas; + recLists[ESM::REC_ARMO] = &armors; + recLists[ESM::REC_BODY] = &bodyParts; + recLists[ESM::REC_BOOK] = &books; + recLists[ESM::REC_BSGN] = &birthSigns; + recLists[ESM::REC_CELL] = &cells; + recLists[ESM::REC_CLAS] = &classes; + recLists[ESM::REC_CLOT] = &clothes; + recLists[ESM::REC_CNTC] = &contChange; + recLists[ESM::REC_CONT] = &containers; + recLists[ESM::REC_CREA] = &creatures; + recLists[ESM::REC_CREC] = &creaChange; + recLists[ESM::REC_DIAL] = &dialogs; + recLists[ESM::REC_DOOR] = &doors; + recLists[ESM::REC_ENCH] = &enchants; + recLists[ESM::REC_FACT] = &factions; + recLists[ESM::REC_GLOB] = &globals; + recLists[ESM::REC_GMST] = &gameSettings; + recLists[ESM::REC_INGR] = &ingreds; + recLists[ESM::REC_LAND] = &lands; + recLists[ESM::REC_LEVC] = &creatureLists; + recLists[ESM::REC_LEVI] = &itemLists; + recLists[ESM::REC_LIGH] = &lights; + recLists[ESM::REC_LOCK] = &lockpicks; + recLists[ESM::REC_LTEX] = &landTexts; + recLists[ESM::REC_MISC] = &miscItems; + recLists[ESM::REC_NPC_] = &npcs; + recLists[ESM::REC_NPCC] = &npcChange; + recLists[ESM::REC_PGRD] = &pathgrids; + recLists[ESM::REC_PROB] = &probes; + recLists[ESM::REC_RACE] = &races; + recLists[ESM::REC_REGN] = ®ions; + recLists[ESM::REC_REPA] = &repairs; + recLists[ESM::REC_SCPT] = &scripts; + recLists[ESM::REC_SNDG] = &soundGens; + recLists[ESM::REC_SOUN] = &sounds; + recLists[ESM::REC_SPEL] = &spells; + recLists[ESM::REC_SSCR] = &startScripts; + recLists[ESM::REC_STAT] = &statics; + recLists[ESM::REC_WEAP] = &weapons; + } + + void load(ESM::ESMReader &esm); + }; +} + +#endif diff --git a/apps/openmw/mwworld/globals.cpp b/apps/openmw/mwworld/globals.cpp index 1430219d91..f904dd2b15 100644 --- a/apps/openmw/mwworld/globals.cpp +++ b/apps/openmw/mwworld/globals.cpp @@ -3,7 +3,7 @@ #include <stdexcept> -#include <components/esm_store/store.hpp> +#include "esmstore.hpp" namespace MWWorld { @@ -27,9 +27,9 @@ namespace MWWorld return iter; } - Globals::Globals (const ESMS::ESMStore& store) + Globals::Globals (const MWWorld::ESMStore& store) { - for (ESMS::RecListT<ESM::Global>::MapType::const_iterator iter + for (MWWorld::RecListT<ESM::Global>::MapType::const_iterator iter (store.globals.list.begin()); iter != store.globals.list.end(); ++iter) { char type = ' '; diff --git a/apps/openmw/mwworld/globals.hpp b/apps/openmw/mwworld/globals.hpp index 6aa54ade29..c7aee5f939 100644 --- a/apps/openmw/mwworld/globals.hpp +++ b/apps/openmw/mwworld/globals.hpp @@ -6,13 +6,10 @@ #include <components/interpreter/types.hpp> -namespace ESMS -{ - struct ESMStore; -} - namespace MWWorld { + class ESMStore; + class Globals { public: @@ -36,7 +33,7 @@ namespace MWWorld public: - Globals (const ESMS::ESMStore& store); + Globals (const MWWorld::ESMStore& store); const Data& operator[] (const std::string& name) const; diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index 179a484e9b..a69d658b36 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -6,13 +6,12 @@ #include <components/esm/loadench.hpp> -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwmechanics/npcstats.hpp" +#include "esmstore.hpp" #include "class.hpp" void MWWorld::InventoryStore::copySlots (const InventoryStore& store) diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index d0d698feb6..4a965ef3d6 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -1,8 +1,6 @@ - #include "localscripts.hpp" -#include <components/esm_store/store.hpp> - +#include "esmstore.hpp" #include "cellstore.hpp" namespace @@ -23,7 +21,7 @@ namespace } } -MWWorld::LocalScripts::LocalScripts (const ESMS::ESMStore& store) : mStore (store) {} +MWWorld::LocalScripts::LocalScripts (const MWWorld::ESMStore& store) : mStore (store) {} void MWWorld::LocalScripts::setIgnore (const Ptr& ptr) { diff --git a/apps/openmw/mwworld/localscripts.hpp b/apps/openmw/mwworld/localscripts.hpp index 78f65e356e..028dcdedad 100644 --- a/apps/openmw/mwworld/localscripts.hpp +++ b/apps/openmw/mwworld/localscripts.hpp @@ -6,13 +6,9 @@ #include "ptr.hpp" -namespace ESMS -{ - struct ESMStore; -} - namespace MWWorld { + struct ESMStore; class CellStore; /// \brief List of active local scripts @@ -21,11 +17,11 @@ namespace MWWorld std::list<std::pair<std::string, Ptr> > mScripts; std::list<std::pair<std::string, Ptr> >::iterator mIter; MWWorld::Ptr mIgnore; - const ESMS::ESMStore& mStore; + const MWWorld::ESMStore& mStore; public: - LocalScripts (const ESMS::ESMStore& store); + LocalScripts (const MWWorld::ESMStore& store); void setIgnore (const Ptr& ptr); ///< Mark a single reference for ignoring during iteration over local scripts (will revoke diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index 6570761ab7..3bc617817f 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -3,8 +3,7 @@ #include <boost/any.hpp> -#include <components/esm_store/store.hpp> - +#include "esmstore.hpp" #include "ptr.hpp" #include "cellstore.hpp" @@ -20,7 +19,7 @@ namespace MWWorld ManualRef& operator= (const ManualRef&); template<typename T> - bool create (const ESMS::RecListT<T>& list, const std::string& name) + bool create (const MWWorld::RecListT<T>& list, const std::string& name) { if (const T *instance = list.search (name)) { @@ -37,7 +36,7 @@ namespace MWWorld } template<typename T> - bool create (const ESMS::RecListWithIDT<T>& list, const std::string& name) + bool create (const MWWorld::RecListWithIDT<T>& list, const std::string& name) { if (const T *instance = list.search (name)) { @@ -55,7 +54,7 @@ namespace MWWorld public: - ManualRef (const ESMS::ESMStore& store, const std::string& name) + ManualRef (const MWWorld::ESMStore& store, const std::string& name) { // create if (!create (store.activators, name) && diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index e1eb02c32b..3aaf2ae48d 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -1,7 +1,6 @@ #include "player.hpp" -#include <components/esm_store/store.hpp> #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" @@ -9,6 +8,7 @@ #include "../mwmechanics/movement.hpp" #include "../mwmechanics/npcstats.hpp" +#include "esmstore.hpp" #include "class.hpp" namespace MWWorld diff --git a/components/esm_store/reclists.hpp b/apps/openmw/mwworld/reclists.hpp similarity index 91% rename from components/esm_store/reclists.hpp rename to apps/openmw/mwworld/reclists.hpp index d9a7648054..1548049ae8 100644 --- a/components/esm_store/reclists.hpp +++ b/apps/openmw/mwworld/reclists.hpp @@ -1,7 +1,7 @@ -#ifndef _GAME_ESM_RECLISTS_H -#define _GAME_ESM_RECLISTS_H +#ifndef OPENMW_MWWORLD_RECLISTS_H +#define OPENMW_MWWORLD_RECLISTS_H -#include "components/esm/records.hpp" +#include <components/esm/records.hpp> #include <map> #include <string> #include <vector> @@ -10,21 +10,17 @@ #include <cassert> #include <stdexcept> #include <iterator> -#include <boost/algorithm/string.hpp> - - +#include <boost/algorithm/string.hpp> using namespace boost::algorithm; -namespace ESMS +namespace MWWorld { - using namespace ESM; - struct RecList { virtual ~RecList() {} - virtual void load(ESMReader &esm, const std::string &id) = 0; + virtual void load(ESM::ESMReader &esm, const std::string &id) = 0; virtual int getSize() = 0; virtual void listIdentifier (std::vector<std::string>& identifier) const = 0; @@ -51,7 +47,7 @@ namespace ESMS MapType list; // Load one object of this type - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { std::string id2 = toLower (id); list[id2].load(esm); @@ -102,7 +98,7 @@ namespace ESMS MapType list; // Load one object of this type - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { //std::string id2 = toLower (id); @@ -170,7 +166,7 @@ namespace ESMS MapType list; // Load one object of this type - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { std::string id2 = toLower (id); list[id2].mId = id2; @@ -216,7 +212,7 @@ namespace ESMS virtual ~LTexList() {} // TODO: For multiple ESM/ESP files we need one list per file. - std::vector<LandTexture> ltex; + std::vector<ESM::LandTexture> ltex; LTexList() { @@ -224,7 +220,7 @@ namespace ESMS ltex.reserve(128); } - const LandTexture* search(size_t index) const + const ESM::LandTexture* search(size_t index) const { assert(index < ltex.size()); return <ex.at(index); @@ -235,9 +231,9 @@ namespace ESMS virtual void listIdentifier (std::vector<std::string>& identifier) const {} - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { - LandTexture lt; + ESM::LandTexture lt; lt.load(esm); lt.mId = id; @@ -265,7 +261,7 @@ namespace ESMS // Map containing all landscapes typedef std::pair<int, int> LandCoord; - typedef std::map<LandCoord, Land*> LandMap; + typedef std::map<LandCoord, ESM::Land*> LandMap; LandMap lands; int count; @@ -275,7 +271,7 @@ namespace ESMS virtual void listIdentifier (std::vector<std::string>& identifier) const {} // Find land for the given coordinates. Return null if no mData. - Land *search(int x, int y) const + ESM::Land *search(int x, int y) const { LandMap::const_iterator itr = lands.find(std::make_pair (x, y)); if ( itr == lands.end() ) @@ -286,13 +282,13 @@ namespace ESMS return itr->second; } - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { count++; // Create the structure and load it. This actually skips the // landscape data and remembers the file position for later. - Land *land = new Land(); + ESM::Land *land = new ESM::Land(); land->load(esm); // Store the structure @@ -404,7 +400,7 @@ namespace ESMS return 0; } - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { count++; @@ -458,7 +454,7 @@ namespace ESMS // do nothing } - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { count++; ESM::Pathgrid *grid = new ESM::Pathgrid; @@ -473,9 +469,9 @@ namespace ESMS } } - Pathgrid *find(int cellX, int cellY, const std::string &cellName) const + ESM::Pathgrid *find(int cellX, int cellY, const std::string &cellName) const { - Pathgrid *result = search(cellX, cellY, cellName); + ESM::Pathgrid *result = search(cellX, cellY, cellName); if (!result) { throw std::runtime_error("no pathgrid found for cell " + cellName); @@ -483,9 +479,9 @@ namespace ESMS return result; } - Pathgrid *search(int cellX, int cellY, const std::string &cellName) const + ESM::Pathgrid *search(int cellX, int cellY, const std::string &cellName) const { - Pathgrid *result = NULL; + ESM::Pathgrid *result = NULL; if (cellX == 0 && cellY == 0) // possibly interior { IntGrids::const_iterator it = intGrids.find(cellName); @@ -501,7 +497,7 @@ namespace ESMS return result; } - Pathgrid *search(const ESM::Cell &cell) const + ESM::Pathgrid *search(const ESM::Cell &cell) const { int cellX, cellY; if (cell.mData.mFlags & ESM::Cell::Interior) @@ -527,7 +523,7 @@ namespace ESMS MapType list; // Load one object of this type - void load(ESMReader &esm, const std::string &id) + void load(ESM::ESMReader &esm, const std::string &id) { X ref; ref.load (esm); @@ -579,7 +575,7 @@ namespace ESMS MapType list; - void load(ESMReader &esm) + void load(ESM::ESMReader &esm) { X ref; ref.load (esm); @@ -620,10 +616,5 @@ namespace ESMS return object; } }; - - /* We need special lists for: - - Path grids - */ } #endif diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 517025fb2f..c3b2ea8647 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -1,6 +1,5 @@ #include "scene.hpp" -#include <components/esm_store/store.hpp> #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" /// FIXME @@ -10,6 +9,7 @@ #include "player.hpp" #include "localscripts.hpp" +#include "esmstore.hpp" #include "cellfunctors.hpp" diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 391b34a840..c49f8e6bbd 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -5,8 +5,6 @@ #include <boost/algorithm/string.hpp> -#include <components/esm_store/store.hpp> - #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" @@ -14,6 +12,7 @@ #include "../mwrender/renderingmanager.hpp" #include "player.hpp" +#include "esmstore.hpp" using namespace Ogre; using namespace MWWorld; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c7f0de245e..a6b34d542a 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -20,7 +20,7 @@ using namespace Ogre; namespace { template<typename T> - void listCellScripts (const ESMS::ESMStore& store, + void listCellScripts (const MWWorld::ESMStore& store, MWWorld::CellRefList<T>& cellRefList, MWWorld::LocalScripts& localScripts, MWWorld::Ptr::CellStore *cell) { @@ -228,12 +228,12 @@ namespace MWWorld return cell; // didn't work -> now check for regions - std::string cellName2 = ESMS::RecListT<ESM::Region>::toLower (cellName); + std::string cellName2 = MWWorld::RecListT<ESM::Region>::toLower (cellName); - for (ESMS::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin()); + for (MWWorld::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin()); iter!=mStore.regions.list.end(); ++iter) { - if (ESMS::RecListT<ESM::Region>::toLower (iter->second.mName)==cellName2) + if (MWWorld::RecListT<ESM::Region>::toLower (iter->second.mName)==cellName2) { if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first)) return cell; @@ -260,7 +260,7 @@ namespace MWWorld return *mPlayer; } - const ESMS::ESMStore& World::getStore() const + const MWWorld::ESMStore& World::getStore() const { return mStore; } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 527a608a6f..68a5ec142f 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -1,12 +1,11 @@ #ifndef GAME_MWWORLD_WORLDIMP_H #define GAME_MWWORLD_WORLDIMP_H -#include <components/esm_store/store.hpp> - #include "../mwrender/debugging.hpp" #include "ptr.hpp" #include "scene.hpp" +#include "esmstore.hpp" #include "physicssystem.hpp" #include "cells.hpp" #include "localscripts.hpp" @@ -56,7 +55,7 @@ namespace MWWorld MWWorld::Scene *mWorldScene; MWWorld::Player *mPlayer; ESM::ESMReader mEsm; - ESMS::ESMStore mStore; + MWWorld::ESMStore mStore; LocalScripts mLocalScripts; MWWorld::Globals *mGlobalVariables; MWWorld::PhysicsSystem *mPhysics; @@ -124,7 +123,7 @@ namespace MWWorld virtual Player& getPlayer(); - virtual const ESMS::ESMStore& getStore() const; + virtual const MWWorld::ESMStore& getStore() const; virtual ESM::ESMReader& getEsmReader(); diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index c714693c3a..29d6f46cdb 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -34,10 +34,6 @@ add_component_dir (file_finder file_finder filename_less search ) -add_component_dir (esm_store - reclists store - ) - add_component_dir (esm attr defs esmcommon esmreader esmwriter loadacti loadalch loadappa loadarmo loadbody loadbook loadbsgn loadcell loadclas loadclot loadcont loadcrea loadcrec loaddial loaddoor loadench loadfact loadglob loadgmst diff --git a/components/esm_store/store.hpp b/components/esm_store/store.hpp deleted file mode 100644 index db36afd330..0000000000 --- a/components/esm_store/store.hpp +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef _GAME_ESM_STORE_H -#define _GAME_ESM_STORE_H - -/* - The ESM storage module. - - This is separate from the ESM loader module, located in esm/. It is - also unaware of the cell loading and storage module. - - The advantage of this, as with all other modularizations, is that - you can replace the storage method later without touching the - loading code. Cutting down dependencies also help on the general - maintainability. - */ - -#include "components/esm/records.hpp" -#include "reclists.hpp" - -namespace ESMS -{ - using namespace ESM; - - struct ESMStore - { - /* Lists all the list types. Mostly used for quick lookup on - loading. The key is the record name (4 chars) parsed as a 32 - bit int. See esm/records.hpp for the complete list. - */ - RecListList recLists; - - // Each individual list - RecListT<Activator> activators; - RecListWithIDT<Potion> potions; - RecListT<Apparatus> appas; - RecListT<Armor> armors; - RecListT<BodyPart> bodyParts; - RecListWithIDT<Book> books; - RecListT<BirthSign> birthSigns; - RecListT<Class> classes; - RecListT<Clothing> clothes; - RecListT<LoadCNTC> contChange; - RecListT<Container> containers; - RecListWithIDT<Creature> creatures; - RecListT<LoadCREC> creaChange; - RecListCaseT<Dialogue> dialogs; - RecListT<Door> doors; - RecListT<Enchantment> enchants; - RecListT<Faction> factions; - RecListT<Global> globals; - RecListWithIDT<Ingredient> ingreds; - RecListT<CreatureLevList> creatureLists; - RecListT<ItemLevList> itemLists; - RecListT<Light> lights; - RecListT<Tool> lockpicks; - RecListT<Miscellaneous> miscItems; - RecListWithIDT<NPC> npcs; - RecListT<LoadNPCC> npcChange; - RecListT<Probe> probes; - RecListT<Race> races; - RecListT<Region> regions; - RecListT<Repair> repairs; - RecListT<SoundGenerator> soundGens; - RecListT<Sound> sounds; - RecListT<Spell> spells; - RecListT<StartScript> startScripts; - RecListT<Static> statics; - RecListT<Weapon> weapons; - - // Lists that need special rules - CellList cells; - RecListWithIDT<GameSetting> gameSettings; - LandList lands; - LTexList landTexts; - ScriptListT<Script> scripts; - IndexListT<MagicEffect> magicEffects; - IndexListT<Skill> skills; - //RecListT<Pathgrid> pathgrids; - PathgridList pathgrids; - - // Special entry which is hardcoded and not loaded from an ESM - IndexListT<Attribute> attributes; - - // Lookup of all IDs. Makes looking up references faster. Just - // maps the id name to the record type. - typedef std::map<std::string, int> AllMap; - AllMap all; - - // Look up the given ID in 'all'. Returns 0 if not found. - int find(const std::string &id) const - { - AllMap::const_iterator it = all.find(id); - if(it == all.end()) return 0; - return it->second; - } - - ESMStore() - { - recLists[REC_ACTI] = &activators; - recLists[REC_ALCH] = &potions; - recLists[REC_APPA] = &appas; - recLists[REC_ARMO] = &armors; - recLists[REC_BODY] = &bodyParts; - recLists[REC_BOOK] = &books; - recLists[REC_BSGN] = &birthSigns; - recLists[REC_CELL] = &cells; - recLists[REC_CLAS] = &classes; - recLists[REC_CLOT] = &clothes; - recLists[REC_CNTC] = &contChange; - recLists[REC_CONT] = &containers; - recLists[REC_CREA] = &creatures; - recLists[REC_CREC] = &creaChange; - recLists[REC_DIAL] = &dialogs; - recLists[REC_DOOR] = &doors; - recLists[REC_ENCH] = &enchants; - recLists[REC_FACT] = &factions; - recLists[REC_GLOB] = &globals; - recLists[REC_GMST] = &gameSettings; - recLists[REC_INGR] = &ingreds; - recLists[REC_LAND] = &lands; - recLists[REC_LEVC] = &creatureLists; - recLists[REC_LEVI] = &itemLists; - recLists[REC_LIGH] = &lights; - recLists[REC_LOCK] = &lockpicks; - recLists[REC_LTEX] = &landTexts; - recLists[REC_MISC] = &miscItems; - recLists[REC_NPC_] = &npcs; - recLists[REC_NPCC] = &npcChange; - recLists[REC_PGRD] = &pathgrids; - recLists[REC_PROB] = &probes; - recLists[REC_RACE] = &races; - recLists[REC_REGN] = ®ions; - recLists[REC_REPA] = &repairs; - recLists[REC_SCPT] = &scripts; - recLists[REC_SNDG] = &soundGens; - recLists[REC_SOUN] = &sounds; - recLists[REC_SPEL] = &spells; - recLists[REC_SSCR] = &startScripts; - recLists[REC_STAT] = &statics; - recLists[REC_WEAP] = &weapons; - } - - void load(ESMReader &esm); - }; -} - -#endif From d5628c678ff9e0de4b79df3396ab5292430d9384 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sun, 7 Oct 2012 21:24:47 +0400 Subject: [PATCH 112/255] add mId field to every record indexed by id --- components/esm/loadacti.hpp | 2 +- components/esm/loadappa.hpp | 2 +- components/esm/loadarmo.hpp | 2 +- components/esm/loadbody.hpp | 2 +- components/esm/loadbsgn.hpp | 2 +- components/esm/loadclas.hpp | 2 +- components/esm/loadclot.hpp | 2 +- components/esm/loadcont.hpp | 2 +- components/esm/loadcrec.hpp | 6 ++++++ components/esm/loaddoor.hpp | 2 +- components/esm/loadench.hpp | 3 +++ components/esm/loadglob.hpp | 3 +++ components/esm/loadlevlist.hpp | 1 + components/esm/loadligh.hpp | 2 +- components/esm/loadlocks.hpp | 2 +- components/esm/loadmisc.hpp | 2 +- components/esm/loadnpcc.hpp | 4 ++++ components/esm/loadrace.hpp | 2 +- components/esm/loadregn.hpp | 2 +- components/esm/loadsndg.hpp | 2 +- components/esm/loadsoun.hpp | 2 +- components/esm/loadspel.hpp | 2 +- components/esm/loadsscr.hpp | 2 +- components/esm/loadstat.hpp | 2 +- components/esm/loadweap.hpp | 2 +- 25 files changed, 37 insertions(+), 20 deletions(-) diff --git a/components/esm/loadacti.hpp b/components/esm/loadacti.hpp index 86c2f44c4d..8cb335feb2 100644 --- a/components/esm/loadacti.hpp +++ b/components/esm/loadacti.hpp @@ -11,7 +11,7 @@ class ESMWriter; struct Activator { - std::string mName, mScript, mModel; + std::string mId, mName, mScript, mModel; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadappa.hpp b/components/esm/loadappa.hpp index 101c39f414..486a559f89 100644 --- a/components/esm/loadappa.hpp +++ b/components/esm/loadappa.hpp @@ -32,7 +32,7 @@ struct Apparatus }; AADTstruct mData; - std::string mModel, mIcon, mScript, mName; + std::string mId, mModel, mIcon, mScript, mName; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadarmo.hpp b/components/esm/loadarmo.hpp index 57c9ccf125..a94ae67353 100644 --- a/components/esm/loadarmo.hpp +++ b/components/esm/loadarmo.hpp @@ -84,7 +84,7 @@ struct Armor AODTstruct mData; PartReferenceList mParts; - std::string mName, mModel, mIcon, mScript, mEnchant; + std::string mId, mName, mModel, mIcon, mScript, mEnchant; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadbody.hpp b/components/esm/loadbody.hpp index 8a05d9924d..c91bb40bf2 100644 --- a/components/esm/loadbody.hpp +++ b/components/esm/loadbody.hpp @@ -52,7 +52,7 @@ struct BodyPart }; BYDTstruct mData; - std::string mModel, mName; + std::string mId, mModel, mName; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadbsgn.hpp b/components/esm/loadbsgn.hpp index ac4050878f..b0bc28be48 100644 --- a/components/esm/loadbsgn.hpp +++ b/components/esm/loadbsgn.hpp @@ -13,7 +13,7 @@ class ESMWriter; struct BirthSign { - std::string mName, mDescription, mTexture; + std::string mId, mName, mDescription, mTexture; // List of powers and abilities that come with this birth sign. SpellList mPowers; diff --git a/components/esm/loadclas.hpp b/components/esm/loadclas.hpp index 0311002b86..264e342e63 100644 --- a/components/esm/loadclas.hpp +++ b/components/esm/loadclas.hpp @@ -60,7 +60,7 @@ struct Class int mCalc; }; // 60 bytes - std::string mName, mDescription; + std::string mId, mName, mDescription; CLDTstruct mData; void load(ESMReader &esm); diff --git a/components/esm/loadclot.hpp b/components/esm/loadclot.hpp index df64c87d32..623983ccfa 100644 --- a/components/esm/loadclot.hpp +++ b/components/esm/loadclot.hpp @@ -42,7 +42,7 @@ struct Clothing PartReferenceList mParts; - std::string mName, mModel, mIcon, mEnchant, mScript; + std::string mId, mName, mModel, mIcon, mEnchant, mScript; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadcont.hpp b/components/esm/loadcont.hpp index eb1f64d6f2..b66ca086d9 100644 --- a/components/esm/loadcont.hpp +++ b/components/esm/loadcont.hpp @@ -39,7 +39,7 @@ struct Container Unknown = 8 }; - std::string mName, mModel, mScript; + std::string mId, mName, mModel, mScript; float mWeight; // Not sure, might be max total weight allowed? int mFlags; diff --git a/components/esm/loadcrec.hpp b/components/esm/loadcrec.hpp index a95656f63f..6904df15a4 100644 --- a/components/esm/loadcrec.hpp +++ b/components/esm/loadcrec.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_ESM_CREC_H #define OPENMW_ESM_CREC_H +#include <string> + // TODO create implementation files and remove this one #include "esmreader.hpp" @@ -15,6 +17,8 @@ class ESMWriter; /// Changes a creature struct LoadCREC { + std::string mId; + void load(ESMReader &esm) { esm.skipRecord(); @@ -28,6 +32,8 @@ struct LoadCREC /// Changes an item list / container struct LoadCNTC { + std::string mId; + void load(ESMReader &esm) { esm.skipRecord(); diff --git a/components/esm/loaddoor.hpp b/components/esm/loaddoor.hpp index 5c0af52e42..e992a592f6 100644 --- a/components/esm/loaddoor.hpp +++ b/components/esm/loaddoor.hpp @@ -11,7 +11,7 @@ class ESMWriter; struct Door { - std::string mName, mModel, mScript, mOpenSound, mCloseSound; + std::string mId, mName, mModel, mScript, mOpenSound, mCloseSound; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadench.hpp b/components/esm/loadench.hpp index d895493227..999f93ad97 100644 --- a/components/esm/loadench.hpp +++ b/components/esm/loadench.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_ESM_ENCH_H #define OPENMW_ESM_ENCH_H +#include <string> + #include "effectlist.hpp" namespace ESM @@ -32,6 +34,7 @@ struct Enchantment // calculate }; + std::string mId; ENDTstruct mData; EffectList mEffects; diff --git a/components/esm/loadglob.hpp b/components/esm/loadglob.hpp index b85af74bce..302729d2e6 100644 --- a/components/esm/loadglob.hpp +++ b/components/esm/loadglob.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_ESM_GLOB_H #define OPENMW_ESM_GLOB_H +#include <string> + #include "defs.hpp" namespace ESM @@ -15,6 +17,7 @@ class ESMWriter; struct Global { + std::string mId; unsigned mValue; VarType mType; diff --git a/components/esm/loadlevlist.hpp b/components/esm/loadlevlist.hpp index 72b4af92f0..b7db5db360 100644 --- a/components/esm/loadlevlist.hpp +++ b/components/esm/loadlevlist.hpp @@ -33,6 +33,7 @@ struct LeveledListBase // list.) int mFlags; unsigned char mChanceNone; // Chance that none are selected (0-255?) + std::string mId; // Record name used to read references. Must be set before load() is // called. diff --git a/components/esm/loadligh.hpp b/components/esm/loadligh.hpp index c425af6b3b..b3d703cc26 100644 --- a/components/esm/loadligh.hpp +++ b/components/esm/loadligh.hpp @@ -41,7 +41,7 @@ struct Light LHDTstruct mData; - std::string mSound, mScript, mModel, mIcon, mName; + std::string mSound, mScript, mModel, mIcon, mName, mId; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadlocks.hpp b/components/esm/loadlocks.hpp index 72d375cbb7..8e88c548e7 100644 --- a/components/esm/loadlocks.hpp +++ b/components/esm/loadlocks.hpp @@ -36,7 +36,7 @@ struct Tool Data mData; Type mType; - std::string mName, mModel, mIcon, mScript; + std::string mId, mName, mModel, mIcon, mScript; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadmisc.hpp b/components/esm/loadmisc.hpp index 1a34e65041..26d25139cb 100644 --- a/components/esm/loadmisc.hpp +++ b/components/esm/loadmisc.hpp @@ -26,7 +26,7 @@ struct Miscellaneous }; MCDTstruct mData; - std::string mName, mModel, mIcon, mScript; + std::string mId, mName, mModel, mIcon, mScript; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadnpcc.hpp b/components/esm/loadnpcc.hpp index 3da14655f8..79d92397f8 100644 --- a/components/esm/loadnpcc.hpp +++ b/components/esm/loadnpcc.hpp @@ -1,6 +1,8 @@ #ifndef OPENMW_ESM_NPCC_H #define OPENMW_ESM_NPCC_H +#include <string> + // TODO: create implementation files to remove this #include "esmreader.hpp" @@ -76,6 +78,8 @@ class ESMWriter; struct LoadNPCC { + std::string mId; + void load(ESMReader &esm) { esm.skipRecord(); diff --git a/components/esm/loadrace.hpp b/components/esm/loadrace.hpp index 42b2c91a72..91a424c10b 100644 --- a/components/esm/loadrace.hpp +++ b/components/esm/loadrace.hpp @@ -64,7 +64,7 @@ struct Race RADTstruct mData; - std::string mName, mDescription; + std::string mId, mName, mDescription; SpellList mPowers; void load(ESMReader &esm); diff --git a/components/esm/loadregn.hpp b/components/esm/loadregn.hpp index fd0863b5bb..0496ef5af2 100644 --- a/components/esm/loadregn.hpp +++ b/components/esm/loadregn.hpp @@ -42,7 +42,7 @@ struct Region // sleepList refers to a eveled list of creatures you can meet if // you sleep outside in this region. - std::string mName, mSleepList; + std::string mId, mName, mSleepList; std::vector<SoundRef> mSoundList; diff --git a/components/esm/loadsndg.hpp b/components/esm/loadsndg.hpp index dadfbd2393..a6226c1545 100644 --- a/components/esm/loadsndg.hpp +++ b/components/esm/loadsndg.hpp @@ -30,7 +30,7 @@ struct SoundGenerator // Type int mType; - std::string mCreature, mSound; + std::string mId, mCreature, mSound; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadsoun.hpp b/components/esm/loadsoun.hpp index 5443c6cb9d..8f59f690a1 100644 --- a/components/esm/loadsoun.hpp +++ b/components/esm/loadsoun.hpp @@ -17,7 +17,7 @@ struct SOUNstruct struct Sound { SOUNstruct mData; - std::string mSound; + std::string mId, mSound; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadspel.hpp b/components/esm/loadspel.hpp index 5ad1841265..0d5e0be522 100644 --- a/components/esm/loadspel.hpp +++ b/components/esm/loadspel.hpp @@ -38,7 +38,7 @@ struct Spell }; SPDTstruct mData; - std::string mName; + std::string mId, mName; EffectList mEffects; void load(ESMReader &esm); diff --git a/components/esm/loadsscr.hpp b/components/esm/loadsscr.hpp index d180bfcffd..713fe96b52 100644 --- a/components/esm/loadsscr.hpp +++ b/components/esm/loadsscr.hpp @@ -20,7 +20,7 @@ class ESMWriter; struct StartScript { std::string mData; - std::string mScript; + std::string mId, mScript; // Load a record and add it to the list void load(ESMReader &esm); diff --git a/components/esm/loadstat.hpp b/components/esm/loadstat.hpp index ba35fa7183..790a71147c 100644 --- a/components/esm/loadstat.hpp +++ b/components/esm/loadstat.hpp @@ -22,7 +22,7 @@ class ESMWriter; struct Static { - std::string mModel; + std::string mId, mModel; void load(ESMReader &esm); void save(ESMWriter &esm); diff --git a/components/esm/loadweap.hpp b/components/esm/loadweap.hpp index 341a2c86e5..e482d3b109 100644 --- a/components/esm/loadweap.hpp +++ b/components/esm/loadweap.hpp @@ -56,7 +56,7 @@ struct Weapon WPDTstruct mData; - std::string mName, mModel, mIcon, mEnchant, mScript; + std::string mId, mName, mModel, mIcon, mEnchant, mScript; void load(ESMReader &esm); void save(ESMWriter &esm); From e1f2f190d4cb0a04dd5355bdf83480c47de1fe78 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Wed, 24 Oct 2012 12:17:49 +0400 Subject: [PATCH 113/255] base record containers --- apps/openmw/mwworld/storedevel/store.hpp | 402 +++++++++++++++++++++++ 1 file changed, 402 insertions(+) create mode 100644 apps/openmw/mwworld/storedevel/store.hpp diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp new file mode 100644 index 0000000000..d96bd9a3cc --- /dev/null +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -0,0 +1,402 @@ +#ifndef OPENMW_MWWORLD_STORE_H +#define OPENMW_MWWORLD_STORE_H + +#include <cctype> +#include <cassert> +#include <string> +#include <vector> +#include <algorithm> +#include <stdexcept> + +namespace MWWorld +{ + std::string lowerCase(const std::string &in) + { + std::string out = in; + std::transform( + in.begin(), + in.end(), + out.begin(), + (int (*)(int)) std::tolower + ); + + return out; + } + + struct CICompareString + { + struct ci + { + bool operator()(int x, int y) { + return std::tolower(x) < std::tolower(y); + } + }; + + bool operator()(const std::string &x, const std::string &y) { + return std::lexicographical_compare( + x.begin(), + x.end(), + y.begin(), + y.end(), + ci() + ); + } + }; + + struct StoreBase + { + class Compare + { + bool mCaseInsensitive; + + public: + Compare() + : mCaseInsensitive(false) + {} + + Compare(bool ci) + : mCaseInsensitive(ci) + {} + + Compare(const Compare &orig) + : mCaseInsensitive(orig.mCaseInsensitive) + {} + + template<class T> + bool operator()(const T &x, const T &y) { + if (mCaseInsensitive) { + return CICompareString()(x.mId, y.mId); + } + return x.mId < y.mId; + } + + bool isCaseInsensitive() const { + return mCaseInsensitive; + } + + bool equalString(const std::string &x, const std::string &y) const { + if (!mCaseInsensitive) { + return x == y; + } + if (x.length() != y.length()) { + return false; + } + std::string::iterator xit = x.begin(); + std::string::iterator yit = y.begin(); + for (; xit != x.end(); ++xit, ++yit) { + if (std::tolower(*xit) != std::tolower(*yit)) { + return false; + } + } + return true; + } + }; + + virtual ~StoreBase() {} + + virtual void setUp() {} + virtual void listIdentifier(std::vector<std::string> &list) const {} + + virtual int getSize() const = 0; + virtual void load(ESM::ESMReader &esm, const std::string &id) = 0; + }; + + template <class T> + class SharedIterator + { + typedef typename std::vector<T *>::const_iterator Iter; + + Iter mIter; + + public: + SharedIterator() {} + + SharedIterator(const SharedIterator &orig) + : mIter(orig.mIter) + {} + + SharedIterator(const Iter &iter) + : mIter(iter) + {} + + SharedIterator &operator++() { + ++mIter; + return *this; + } + + SharedIterator operator++(int) { + SharedIterator iter = *this; + mIter++; + + return iter; + } + + SharedIterator &operator--() { + --mIter; + return *this; + } + + SharedIterator operator--(int) { + SharedIterator iter = *this; + mIter--; + + return iter; + } + + SharedIterator operator==(const SharedIterator &x) const { + return mIter == x.mIter; + } + + SharedIterator operator!=(const SharedIterator &x) const { + return !(*this == x); + } + + const T &operator*() const { + return **mIter; + } + + const T *operator->() const { + return &(**mIter); + } + }; + + template <class T> + class Store : public StoreBase + { + Compare mComp; + std::vector<T> mData; + std::vector<T *> mShared; + + public: + Store() {} + + Store(bool ci) + : mComp(ci) + {} + + Store(const Store<T> &orig) + : mComp(orig.mComp), mData(orig.mData) + {} + + typedef SharedIterator<T> iterator; + + const T* search(const std::string &id) const { + T item; + item.mId = lowerCase(id); + + typename std::vector<T>::const_iterator it = + std::lower_bound(mData.begin(), mData.end(), item, mComp); + + if (it != mData.end() && mComp.equalString(it->mId, item.mId)) { + return &(*it); + } + return 0; + } + + const T *find(const std::string &id) const { + const T *ptr = search(id); + if (ptr == 0) { + throw std::runtime_error("object '" + id + "' not found"); + } + return ptr; + } + + void setUp() { + std::sort(mData.begin(), mData.end(), mComp); + + mShared.reserve(mData.size()); + typename std::vector<T>::iterator it = mData.begin(); + for (; it != mData.end(); ++it) { + mShared.push_back(&(*it)); + } + } + + iterator begin() { + return mShared.begin(); + } + + iterator end() { + return mShared.end(); + } + }; + + template <> + class Store<ESM::LandTexture> : public StoreBase + { + std::vector<ESM::LandTexture> mData; + + public: + Store<ESM::LandTexture>() { + mData.reserve(128); + } + + typedef std::vector<ESM::LandTexture>::const_iterator iterator; + + const ESM::LandTexture *search(size_t index) const { + if (index < mData.size()) { + return &mData.at(index); + } + return 0; + } + + const ESM::LandTexture *find(size_t index) const { + ESM::LandTexture *ptr = search(index); + if (ptr == 0) { + throw std::runtime_error( + "Land texture with index " + index " not found" + ); + } + return ptr; + } + + int getSize() const { + return mData.size(); + } + + int load(ESM::ESMReader &esm, const std::string &id) { + ESM::LandTexture ltex; + ltex.load(esm); + + if (ltex.mIndex >= (int) mData.size()) { + mData.resize(ltex.mIndex + 1); + } + mData[ltex.mIndex] = ltex; + mData[ltex.mIndex].mId = id; + } + + iterator begin() { + return mData.begin(); + } + + iterator end() { + return mData.end(); + } + }; + + template <> + class Store<ESM::Land> : public StoreBase + { + std::vector<ESM::Land> mData; + + struct Compare + { + bool operator()(const ESM::Land &x, const ESM::Land &y) { + if (x.mX == y.mX) { + return x.mY < y.mY; + } + return x.mX < y.mX; + } + }; + + public: + typedef typename std::vector<ESM::Land>::const_iterator iterator; + + int getSize() const { + return mData.size(); + } + + iterator begin() { + return mData.begin(); + } + + iterator end() { + return mData.end(); + } + + ESM::Land *search(int x, int y) const { + ESM::Land land; + land.mX = x, land.mY = y; + + std::vector<ESM::Land>::iterator it = + std::lower_bound(mData.begin(), mData.end(), land, Compare()); + + if (it != mData.end() && it->mX == x && it->mY == y) { + return &(*it); + } + return 0; + } + + ESM::Land *find(int x, int y) const { + ESM::Land *ptr = search(x, y); + if (ptr == 0) { + throw std::runtime_error( + "Land at (" + x + ", " + y + ") not found" + ); + } + return ptr; + } + + void load(ESM::ESMReader &esm, const std::string &id) { + mData.push_back(ESM::Land()); + mData.back().load(esm); + } + + void setUp() { + std::sort(mData.begin(), mData.end(), Compare()); + } + }; + + template <> + class Store<ESM::Cell> : public StoreBase + { + Compare mIntCmp; + std::vector<ESM::Cell> mInt; + std::vector<ESM::Cell> mExt; + + public: + Store<ESM::Cell>() + : mIntCmp(true) + {} + + typedef std::vector<ESM::Cell>::const_iterator iterator; + + const ESM::Cell *search(const std::string &id) const { + ESM::Cell cell; + + iterator it = + std::lower_bound(mInt.begin(), mInt.end(), cell, mIntCmp); + + if (it != mInt.end() && mIntCmp.equalString(it->mId, id)) { + return &(*it); + } + return 0; + } + + const ESM::Cell *search(int x, int y) const { + return 0; + } + + const ESM::Cell *find(const std::string &id) const { + ESM::Cell *ptr = search(id); + if (ptr == 0) { + throw std::runtime_error( + "Interior cell '" + id + "' not found" + ); + } + return ptr; + } + + const ESM::Cell *find(int x, int y) const { + ESM::Cell *ptr = search(x, y); + if (ptr == 0) { + throw std::runtime_error( + "Exterior cell at (" + x + ", " + y + ") not found" + ); + } + return ptr; + } + }; + + template <> + class Store<ESM::Pathgrid> : public StoreBase + { + }; + + template <> + class Store<ESM::Script> + { + }; + +} //end namespace + +#endif From 3b86955d37e8f7e0c10f5a54512ce17a5f26ce08 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Fri, 26 Oct 2012 18:52:44 +0400 Subject: [PATCH 114/255] basic Cell store --- apps/openmw/mwworld/storedevel/store.hpp | 144 ++++++++++++++++++++++- 1 file changed, 139 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index d96bd9a3cc..1dec6e87cb 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -70,6 +70,14 @@ namespace MWWorld return x.mId < y.mId; } + template <> + bool operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) { + if (mCaseInsensitive) { + return CICompareString()(x.mName, y.mName); + } + return x.mName < y.mName; + } + bool isCaseInsensitive() const { return mCaseInsensitive; } @@ -218,6 +226,18 @@ namespace MWWorld iterator end() { return mShared.end(); } + + int getSize() const { + return mShared.size(); + } + + void listIdentifier(std::vector<std::string> &list) const { + list.reserve(list.size() + getSize()); + typename std::vector<T *>::iterator it = mShared.begin(); + for (; it != mShared.end(); ++it) { + list.push_back((*it)->mId); + } + } }; template <> @@ -339,30 +359,66 @@ namespace MWWorld template <> class Store<ESM::Cell> : public StoreBase { + public: + typedef std::vector<ESM::Cell>::const_iterator iterator; + + private: + struct ExtCompare + { + bool operator()(const ESM::Cell &x, const ESM::Cell &y) { + if (x.mData.mX == y.mData.mX) { + return x.mData.mY < y.mData.mY; + } + return x.mData.mX < y.mData.mX; + } + }; + + struct IntExtOrdering + { + bool operator()(const ESM::Cell &x, const ESM::Cell &y) { + // interiors precedes exteriors (x < y) + if ((x.mData.mFlags & ESM::Cell::Interior) != 0 && + (y.mData.mFlags & ESM::Cell::Interior) == 0) + { + return true; + } + return false; + } + }; + Compare mIntCmp; - std::vector<ESM::Cell> mInt; - std::vector<ESM::Cell> mExt; + std::vector<ESM::Cell> mData; + iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; public: Store<ESM::Cell>() : mIntCmp(true) {} - typedef std::vector<ESM::Cell>::const_iterator iterator; const ESM::Cell *search(const std::string &id) const { ESM::Cell cell; + cell.mName = id; iterator it = - std::lower_bound(mInt.begin(), mInt.end(), cell, mIntCmp); + std::lower_bound(mIntBegin, mIntEnd, cell, mIntCmp); - if (it != mInt.end() && mIntCmp.equalString(it->mId, id)) { + if (it != mIntEnd && mIntCmp.equalString(it->mId, id)) { return &(*it); } return 0; } const ESM::Cell *search(int x, int y) const { + ESM::Cell cell; + cell.mData.mX = x, cell.mData.mY = y; + + iterator it = + std::lower_bound(mExtBegin, mExtEnd, cell, ExtCompare()); + + if (it != mExtEnd && it->mData.mX == x && it->mData.mY == y) { + return &(*it); + } return 0; } @@ -385,6 +441,84 @@ namespace MWWorld } return ptr; } + + void setUp() { + IntExtOrdering cmp; + std::sort(mData.begin(), mData.end(), cmp); + + ESM::Cell cell; + cell.mData.mFlags = 0; + mExtBegin = std::lower_bound(mData.begin(), mData.end(), cell, cmp); + mExtEnd = mData.end(); + + mIntBegin = mData.begin(); + mIntEnd = mExtBegin; + + std::sort(mIntBegin, mIntEnd, mIntCmp); + std::sort(mExtBegin, mExtEnd, ExtCompare()); + } + + void load(ESM::ESMReader &esm, const std::string &id) { + mData.push_back(ESM::Cell()); + mData.back().mName = id; + mData.back().load(esm); + } + + iterator begin() { + return mData.begin(); + } + + iterator end() { + return mData.end(); + } + + iterator interiorsBegin() { + return mIntBegin; + } + + iterator interiorsEnd() { + return mIntEnd; + } + + iterator exteriorsBegin() { + return mExtBegin; + } + + iterator exteriorsEnd() { + return mExtEnd; + } + + /// \todo implement appropriate index + const ESM::Cell *searchExteriorByName(const std::string &id) { + for (iterator it = mExtBegin; it != mExtEnd; ++it) { + if (mIntCmp.equalString(it->mName, id)) { + return &(*it); + } + } + return 0; + } + + /// \todo implement appropriate index + const ESM::Cell *searchExteriorByRegion(const std::string &id) { + for (iterator it = mExtBegin; it != mExtEnd; ++it) { + if (mIntCmp.equalString(it->mRegion, id)) { + return &(*it); + } + } + return 0; + } + + int getSize() const { + return mData.size(); + } + + void listIdentifier(std::vector<std::string> &list) const { + list.reserve(list.size() + (mIntEnd - mIntBegin)); + std::vector<ESM::Cell>::iterator it = mIntBegin; + for (; it != mIntEnd; ++it) { + list.push_back(it->mName); + } + } }; template <> From f0ecbbb056d0eb26f24017e6c087fcf95a18bb43 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Fri, 26 Oct 2012 20:46:30 +0400 Subject: [PATCH 115/255] basic Pathgrid store --- apps/openmw/mwworld/storedevel/store.hpp | 171 +++++++++++++++++++++-- 1 file changed, 161 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index 1dec6e87cb..899e6ddcdd 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -78,6 +78,14 @@ namespace MWWorld return x.mName < y.mName; } + template <> + bool operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &x) { + if (mCaseInsensitive) { + return CICompareString()(x.mCell, y.mCell); + } + return x.mCell < y.mCell; + } + bool isCaseInsensitive() const { return mCaseInsensitive; } @@ -403,7 +411,7 @@ namespace MWWorld iterator it = std::lower_bound(mIntBegin, mIntEnd, cell, mIntCmp); - if (it != mIntEnd && mIntCmp.equalString(it->mId, id)) { + if (it != mIntEnd && mIntCmp.equalString(it->mName, id)) { return &(*it); } return 0; @@ -448,7 +456,8 @@ namespace MWWorld ESM::Cell cell; cell.mData.mFlags = 0; - mExtBegin = std::lower_bound(mData.begin(), mData.end(), cell, cmp); + mExtBegin = + std::lower_bound(mData.begin(), mData.end(), cell, cmp); mExtEnd = mData.end(); mIntBegin = mData.begin(); @@ -464,32 +473,32 @@ namespace MWWorld mData.back().load(esm); } - iterator begin() { + iterator begin() const { return mData.begin(); } - iterator end() { + iterator end() const { return mData.end(); } - iterator interiorsBegin() { + iterator interiorsBegin() const { return mIntBegin; } - iterator interiorsEnd() { + iterator interiorsEnd() const { return mIntEnd; } - iterator exteriorsBegin() { + iterator exteriorsBegin() const { return mExtBegin; } - iterator exteriorsEnd() { + iterator exteriorsEnd() const { return mExtEnd; } /// \todo implement appropriate index - const ESM::Cell *searchExteriorByName(const std::string &id) { + const ESM::Cell *searchExteriorByName(const std::string &id) const { for (iterator it = mExtBegin; it != mExtEnd; ++it) { if (mIntCmp.equalString(it->mName, id)) { return &(*it); @@ -499,7 +508,7 @@ namespace MWWorld } /// \todo implement appropriate index - const ESM::Cell *searchExteriorByRegion(const std::string &id) { + const ESM::Cell *searchExteriorByRegion(const std::string &id) const { for (iterator it = mExtBegin; it != mExtEnd; ++it) { if (mIntCmp.equalString(it->mRegion, id)) { return &(*it); @@ -524,6 +533,148 @@ namespace MWWorld template <> class Store<ESM::Pathgrid> : public StoreBase { + public: + typedef std::vector<ESM::Pathgrid>::const_iterator iterator; + + private: + Compare mIntCmp; + std::vector<ESM::Pathgrid> mData; + iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; + + struct IntExtOrdering + { + bool operator()(const ESM::Pathgrid &x, const ESM::Pathgrid &y) const { + // interior pathgrids precedes exterior ones (x < y) + if ((x.mData.mX == 0 && x.mData.mY == 0) && + (y.mData.mX != 0 || y.mData.mY != 0)) + { + return false; + } + } + }; + + struct ExtCompare + { + bool operator()(const ESM::Pathgrid &x, const ESM::Pathgrid &y) const { + if (x.mData.mX == y.mData.mX) { + return x.mData.mY < y.mData.mY; + } + return x.mData.mX < y.mData.mX; + } + }; + + public: + Store<ESM::Pathgrid>() + : mIntCmp(true) + {} + + void load(ESM::ESMReader &esm, const std::string &id) { + mData.push_back(ESM::Pathgrid()); + mData.back().load(esm); + } + + int getSize() const { + return mData.size(); + } + + void setUp() { + IntExtOrdering cmp; + std::sort(mData.begin(), mData.end(), cmp); + + ESM::Pathgrid pg; + pg.mData.mX = pg.mData.mY = 1; + mExtBegin = + std::lower_bound(mData.begin(), mData.end(), pg, cmp); + mExtEnd = mData.end(); + + mIntBegin = mData.begin(); + mIntEnd = mExtBegin; + + std::sort(mIntBegin, mIntEnd, mIntCmp); + std::sort(mExtBegin, mExtEnd, ExtCompare()); + } + + const ESM::Pathgrid *search(int x, int y) const { + ESM::Pathgrid pg; + pg.mData.mX = x; + pg.mData.mY = y; + + iterator it = + std::lower_bound(mExtBegin, mExtEnd, pg, ExtCompare()); + if (it != mExtEnd && it->mData.mX == x && it->mData.mY == y) { + return &(*it); + } + return 0; + } + + const ESM::Pathgrid *find(int x, int y) const { + ESM::Pathgrid *ptr = search(x, y); + if (ptr == 0) { + throw std::runtime_error( + "Pathgrid at (" + x + ", " + y + ") not found" + ); + } + return ptr; + } + + const ESM::Pathgrid *search(const std::string &name) const { + ESM::Pathgrid pg; + pg.mCell = name; + + iterator it = std::lower_bound(mIntBegin, mIntEnd, pg, mIntCmp); + if (it != mIntEnd && mIntCmp.equalString(it->mCell, name)) { + return &(*it); + } + return 0; + } + + const ESM::Pathgrid *find(const std::string &name) const { + ESM::Pathgrid *ptr = search(name); + if (ptr == 0) { + throw std::runtime_error( + "Pathgrid in cell '" + name + "' not found" + ); + } + return ptr; + } + + const ESM::Pathgrid *search(const ESM::Cell &cell) const { + if (cell.mData.mFlags & ESM::Cell::Interior) { + return search(cell.mName); + } + return search(cell.mData.mX, cell.mData.mY); + } + + const ESM::Pathgrid *find(const ESM::Cell &cell) const { + if (cell.mData.mFlags & ESM::Cell:Interior) { + return find(cell.mName); + } + return find(cell.mData.mX, cell.mData.mY); + } + + iterator begin() const { + return mData.begin(); + } + + iterator end() const { + return mData.end(); + } + + iterator interiorPathsBegin() const { + return mIntBegin; + } + + iterator interiorPathsEnd() const { + return mIntEnd; + } + + iterator exteriorPathsBegin() const { + return mExtBegin; + } + + iterator exteriorPathsEnd() const { + return mExtEnd; + } }; template <> From 5ac54d1fff1d53869092558adb076e665cef34b9 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Fri, 26 Oct 2012 22:22:55 +0400 Subject: [PATCH 116/255] alter ESM::Script for storing id as std::string --- apps/openmw/mwworld/storedevel/store.hpp | 6 ------ components/esm/loadscpt.cpp | 19 +++++++++++++++++-- components/esm/loadscpt.hpp | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index 899e6ddcdd..9d94e677e9 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -676,12 +676,6 @@ namespace MWWorld return mExtEnd; } }; - - template <> - class Store<ESM::Script> - { - }; - } //end namespace #endif diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index dc28166d44..55a71b6b7f 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -6,9 +6,18 @@ namespace ESM { +struct SCHD +{ + NAME32 mName; + SCHDstruct mData; +}; + void Script::load(ESMReader &esm) { - esm.getHNT(mData, "SCHD", 52); + SCHD data; + esm.getHNT(data, "SCHD", 52); + mData = data.mData; + mId = data.mName.toString(); // List of local variables if (esm.isNextSub("SCVR")) @@ -48,7 +57,13 @@ void Script::save(ESMWriter &esm) for (std::vector<std::string>::iterator it = mVarNames.begin(); it != mVarNames.end(); ++it) varNameString.append(*it); - esm.writeHNT("SCHD", mData, 52); + SCHD data; + memset(&data, 0, sizeof(data)); + + data.mData = mData; + memcpy(data.mName.name, mId.c_str(), mId.size()); + + esm.writeHNT("SCHD", data, 52); if (!mVarNames.empty()) { diff --git a/components/esm/loadscpt.hpp b/components/esm/loadscpt.hpp index db8f850572..10a6d24b10 100644 --- a/components/esm/loadscpt.hpp +++ b/components/esm/loadscpt.hpp @@ -42,13 +42,13 @@ public: approach though. */ - NAME32 mName; - // These describe the sizes we need to allocate for the script // data. int mNumShorts, mNumLongs, mNumFloats, mScriptDataSize, mStringTableSize; }; // 52 bytes + std::string mId; + SCHDstruct mData; std::vector<std::string> mVarNames; // Variable names From ce91c5636da4715054f924ab40646f7dff191014 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Fri, 26 Oct 2012 22:46:24 +0400 Subject: [PATCH 117/255] load() method for records with string id --- apps/openmw/mwworld/storedevel/store.hpp | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index 9d94e677e9..c41fbc64c8 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -184,7 +184,9 @@ namespace MWWorld std::vector<T *> mShared; public: - Store() {} + Store() + : mComp(false) + {} Store(bool ci) : mComp(ci) @@ -217,6 +219,31 @@ namespace MWWorld return ptr; } + void load(ESM::ESMReader &esm, const std::string &id) { + // reduce size of allocated memory to copy + mData.push_back(T()); + + // some records requires id before loading + // make sure that string case is the same across container + if (mComp.isCaseInsensitive()) { + mData.back().mId = id; + } else { + mData.back().mId = lowerCase(id); + } + mData.back().load(esm); + + // allow records to overwrite id on loading + if (!mComp.isCaseInsensitive()) { + std::string &s = mData.back().mId; + std::transform( + s.begin(), + s.end(), + s.begin(), + (int (*)(int)) std::tolower + ); + } + } + void setUp() { std::sort(mData.begin(), mData.end(), mComp); From dd8f5e1a91c61fe64439ae699a444011ef27824e Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 30 Oct 2012 16:14:03 +0400 Subject: [PATCH 118/255] stores for records indexed with int, basic resolving --- apps/openmw/mwworld/storedevel/store.hpp | 273 +++++++++++++++++------ 1 file changed, 208 insertions(+), 65 deletions(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index c41fbc64c8..14ff11e8a0 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -70,22 +70,6 @@ namespace MWWorld return x.mId < y.mId; } - template <> - bool operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) { - if (mCaseInsensitive) { - return CICompareString()(x.mName, y.mName); - } - return x.mName < y.mName; - } - - template <> - bool operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &x) { - if (mCaseInsensitive) { - return CICompareString()(x.mCell, y.mCell); - } - return x.mCell < y.mCell; - } - bool isCaseInsensitive() const { return mCaseInsensitive; } @@ -97,8 +81,8 @@ namespace MWWorld if (x.length() != y.length()) { return false; } - std::string::iterator xit = x.begin(); - std::string::iterator yit = y.begin(); + std::string::const_iterator xit = x.begin(); + std::string::const_iterator yit = y.begin(); for (; xit != x.end(); ++xit, ++yit) { if (std::tolower(*xit) != std::tolower(*yit)) { return false; @@ -117,6 +101,22 @@ namespace MWWorld virtual void load(ESM::ESMReader &esm, const std::string &id) = 0; }; + template <> + bool StoreBase::Compare::operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) { + if (mCaseInsensitive) { + return CICompareString()(x.mName, y.mName); + } + return x.mName < y.mName; + } + + template <> + bool StoreBase::Compare::operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &y) { + if (mCaseInsensitive) { + return CICompareString()(x.mCell, y.mCell); + } + return x.mCell < y.mCell; + } + template <class T> class SharedIterator { @@ -214,7 +214,9 @@ namespace MWWorld const T *find(const std::string &id) const { const T *ptr = search(id); if (ptr == 0) { - throw std::runtime_error("object '" + id + "' not found"); + std::ostringstream msg; + msg << "Object '" << id << "' not found"; + throw std::runtime_error(msg.str()); } return ptr; } @@ -268,7 +270,7 @@ namespace MWWorld void listIdentifier(std::vector<std::string> &list) const { list.reserve(list.size() + getSize()); - typename std::vector<T *>::iterator it = mShared.begin(); + typename std::vector<T *>::const_iterator it = mShared.begin(); for (; it != mShared.end(); ++it) { list.push_back((*it)->mId); } @@ -295,11 +297,11 @@ namespace MWWorld } const ESM::LandTexture *find(size_t index) const { - ESM::LandTexture *ptr = search(index); + const ESM::LandTexture *ptr = search(index); if (ptr == 0) { - throw std::runtime_error( - "Land texture with index " + index " not found" - ); + std::ostringstream msg; + msg << "Land texture with index " << index << " not found"; + throw std::runtime_error(msg.str()); } return ptr; } @@ -308,7 +310,7 @@ namespace MWWorld return mData.size(); } - int load(ESM::ESMReader &esm, const std::string &id) { + void load(ESM::ESMReader &esm, const std::string &id) { ESM::LandTexture ltex; ltex.load(esm); @@ -331,59 +333,61 @@ namespace MWWorld template <> class Store<ESM::Land> : public StoreBase { - std::vector<ESM::Land> mData; + std::vector<ESM::Land *> mData; struct Compare { - bool operator()(const ESM::Land &x, const ESM::Land &y) { - if (x.mX == y.mX) { - return x.mY < y.mY; + bool operator()(const ESM::Land *x, const ESM::Land *y) { + if (x->mX == y->mX) { + return x->mY < y->mY; } - return x.mX < y.mX; + return x->mX < y->mX; } }; public: - typedef typename std::vector<ESM::Land>::const_iterator iterator; + typedef SharedIterator<ESM::Land> iterator; int getSize() const { return mData.size(); } iterator begin() { - return mData.begin(); + return iterator(mData.begin()); } iterator end() { - return mData.end(); + return iterator(mData.end()); } - ESM::Land *search(int x, int y) const { + ESM::Land *search(int x, int y) { ESM::Land land; land.mX = x, land.mY = y; - std::vector<ESM::Land>::iterator it = - std::lower_bound(mData.begin(), mData.end(), land, Compare()); + std::vector<ESM::Land *>::iterator it = + std::lower_bound(mData.begin(), mData.end(), &land, Compare()); - if (it != mData.end() && it->mX == x && it->mY == y) { - return &(*it); + if (it != mData.end() && (*it)->mX == x && (*it)->mY == y) { + return *it; } return 0; } - ESM::Land *find(int x, int y) const { + ESM::Land *find(int x, int y) { ESM::Land *ptr = search(x, y); if (ptr == 0) { - throw std::runtime_error( - "Land at (" + x + ", " + y + ") not found" - ); + std::ostringstream msg; + msg << "Land at (" << x << ", " << y << ") not found"; + throw std::runtime_error(msg.str()); } return ptr; } void load(ESM::ESMReader &esm, const std::string &id) { - mData.push_back(ESM::Land()); - mData.back().load(esm); + ESM::Land *ptr = new ESM::Land(); + ptr->load(esm); + + mData.push_back(ptr); } void setUp() { @@ -423,7 +427,7 @@ namespace MWWorld Compare mIntCmp; std::vector<ESM::Cell> mData; - iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; + std::vector<ESM::Cell>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; public: Store<ESM::Cell>() @@ -458,21 +462,21 @@ namespace MWWorld } const ESM::Cell *find(const std::string &id) const { - ESM::Cell *ptr = search(id); + const ESM::Cell *ptr = search(id); if (ptr == 0) { - throw std::runtime_error( - "Interior cell '" + id + "' not found" - ); + std::ostringstream msg; + msg << "Interior cell '" << id << "' not found"; + throw std::runtime_error(msg.str()); } return ptr; } const ESM::Cell *find(int x, int y) const { - ESM::Cell *ptr = search(x, y); + const ESM::Cell *ptr = search(x, y); if (ptr == 0) { - throw std::runtime_error( - "Exterior cell at (" + x + ", " + y + ") not found" - ); + std::ostringstream msg; + msg << "Exterior at (" << x << ", " << y << ") not found"; + throw std::runtime_error(msg.str()); } return ptr; } @@ -550,8 +554,7 @@ namespace MWWorld void listIdentifier(std::vector<std::string> &list) const { list.reserve(list.size() + (mIntEnd - mIntBegin)); - std::vector<ESM::Cell>::iterator it = mIntBegin; - for (; it != mIntEnd; ++it) { + for (iterator it = mIntBegin; it != mIntEnd; ++it) { list.push_back(it->mName); } } @@ -566,7 +569,8 @@ namespace MWWorld private: Compare mIntCmp; std::vector<ESM::Pathgrid> mData; - iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; + + std::vector<ESM::Pathgrid>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; struct IntExtOrdering { @@ -635,11 +639,11 @@ namespace MWWorld } const ESM::Pathgrid *find(int x, int y) const { - ESM::Pathgrid *ptr = search(x, y); + const ESM::Pathgrid *ptr = search(x, y); if (ptr == 0) { - throw std::runtime_error( - "Pathgrid at (" + x + ", " + y + ") not found" - ); + std::ostringstream msg; + msg << "Pathgrid at (" << x << ", " << y << ") not found"; + throw std::runtime_error(msg.str()); } return ptr; } @@ -656,11 +660,11 @@ namespace MWWorld } const ESM::Pathgrid *find(const std::string &name) const { - ESM::Pathgrid *ptr = search(name); + const ESM::Pathgrid *ptr = search(name); if (ptr == 0) { - throw std::runtime_error( - "Pathgrid in cell '" + name + "' not found" - ); + std::ostringstream msg; + msg << "Pathgrid in cell '" << name << "' not found"; + throw std::runtime_error(msg.str()); } return ptr; } @@ -673,7 +677,7 @@ namespace MWWorld } const ESM::Pathgrid *find(const ESM::Cell &cell) const { - if (cell.mData.mFlags & ESM::Cell:Interior) { + if (cell.mData.mFlags & ESM::Cell::Interior) { return find(cell.mName); } return find(cell.mData.mX, cell.mData.mY); @@ -703,6 +707,145 @@ namespace MWWorld return mExtEnd; } }; + + template <class T> + class IndexedStore + { + struct Compare + { + bool operator()(const T &x, const T &y) const { + return x.mIndex < y.mIndex; + } + }; + protected: + std::vector<T> mData; + + public: + typedef typename std::vector<T>::const_iterator iterator; + + IndexedStore() {} + + IndexedStore(unsigned int size) { + mData.reserve(size); + } + + iterator begin() const { + return mData.begin(); + } + + iterator end() const { + return mData.end(); + } + + /// \todo refine loading order + void load(ESM::ESMReader &esm) { + mData.push_back(T()); + mData.back().load(esm); + } + + int getSize() const { + return mData.size(); + } + + void setUp() { + std::sort(mData.begin(), mData.end(), Compare()); + } + + const T *search(int index) const { + T item; + item.mIndex = index; + + iterator it = + std::lower_bound(mData.begin(), mData.end(), item, Compare()); + if (it != mData.end() && it->mIndex == index) { + return &(*it); + } + return 0; + } + + const T *find(int index) const { + T *ptr = search(index); + if (ptr == 0) { + std::ostringstream msg; + msg << "Object with index " << index << " not found"; + throw std::runtime_error(msg.str()); + } + return ptr; + } + }; + + template <> + struct Store<ESM::Skill> : public IndexedStore<ESM::Skill> + { + Store() {} + Store(unsigned int size) + : IndexedStore<ESM::Skill>(size) + {} + }; + + template <> + struct Store<ESM::MagicEffect> : public IndexedStore<ESM::MagicEffect> + { + Store() {} + Store(unsigned int size) + : IndexedStore<ESM::MagicEffect>(size) + {} + }; + + template <> + class Store<ESM::Attribute> : public IndexedStore<ESM::Attribute> + { + std::vector<ESM::Attribute> mData; + + public: + typedef std::vector<ESM::Attribute>::const_iterator iterator; + + Store() { + mData.reserve(ESM::Attribute::Length); + } + + const ESM::Attribute *search(int index) const { + if (index < 0 || index >= mData.size()) { + return 0; + } + return &mData.at(index); + } + + const ESM::Attribute *find(int index) const { + const ESM::Attribute *ptr = search(index); + if (ptr == 0) { + std::ostringstream msg; + msg << "Attribute with index " << index << " not found"; + throw std::runtime_error(msg.str()); + } + return ptr; + } + + void setUp() { + for (int i = 0; i < ESM::Attribute::Length; ++i) { + mData.push_back( + ESM::Attribute( + ESM::Attribute::sAttributeIds[i], + ESM::Attribute::sGmstAttributeIds[i], + ESM::Attribute::sGmstAttributeDescIds[i] + ) + ); + } + } + + int getSize() const { + return mData.size(); + } + + iterator begin() const { + return mData.begin(); + } + + iterator end() const { + return mData.end(); + } + }; + } //end namespace #endif From 558e0557d08b17e7d3484bb1ab181911c5721ad4 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 30 Oct 2012 17:14:27 +0400 Subject: [PATCH 119/255] basic static esmstore --- apps/openmw/mwworld/storedevel/esmstore.cpp | 100 ++++++ apps/openmw/mwworld/storedevel/esmstore.hpp | 362 ++++++++++++++++++++ 2 files changed, 462 insertions(+) create mode 100644 apps/openmw/mwworld/storedevel/esmstore.cpp create mode 100644 apps/openmw/mwworld/storedevel/esmstore.hpp diff --git a/apps/openmw/mwworld/storedevel/esmstore.cpp b/apps/openmw/mwworld/storedevel/esmstore.cpp new file mode 100644 index 0000000000..eb236d1bc2 --- /dev/null +++ b/apps/openmw/mwworld/storedevel/esmstore.cpp @@ -0,0 +1,100 @@ +#include "esmstore.hpp" + +#include <set> +#include <iostream> + +namespace MWWorld +{ + +static bool isCacheableRecord(int id) +{ + if (id == ESM::REC_ACTI || id == ESM::REC_ALCH || id == ESM::REC_APPA || id == ESM::REC_ARMO || + id == ESM::REC_BOOK || id == ESM::REC_CLOT || id == ESM::REC_CONT || id == ESM::REC_CREA || + id == ESM::REC_DOOR || id == ESM::REC_INGR || id == ESM::REC_LEVC || id == ESM::REC_LEVI || + id == ESM::REC_LIGH || id == ESM::REC_LOCK || id == ESM::REC_MISC || id == ESM::REC_NPC_ || + id == ESM::REC_PROB || id == ESM::REC_REPA || id == ESM::REC_STAT || id == ESM::REC_WEAP) + { + return true; + } + return false; +} + +void ESMStore::load(ESM::ESMReader &esm) +{ + std::set<std::string> missing; + + ESM::Dialogue *dialogue = 0; + + // Loop through all records + while(esm.hasMoreRecs()) + { + ESM::NAME n = esm.getRecName(); + esm.getRecHeader(); + + // Look up the record type. + std::map<int, StoreBase *>::iterator it = mStores.find(n.val); + + if (it == mStores.end()) { + if (n.val == ESM::REC_INFO) { + if (dialogue) { + dialogue->mInfo.push_back(ESM::DialInfo()); + dialogue->mInfo.back().load(esm); + } else { + std::cerr << "error: info record without dialog" << std::endl; + esm.skipRecord(); + } + } else if (n.val == ESM::REC_MGEF) { + mMagicEffects.load (esm); + } else if (n.val == ESM::REC_SKIL) { + mSkills.load (esm); + } else { + // Not found (this would be an error later) + esm.skipRecord(); + missing.insert(n.toString()); + } + } else { + // Load it + std::string id = esm.getHNOString("NAME"); + it->second->load(esm, id); + + if (n.val==ESM::REC_DIAL) { + // dirty hack, but it is better than non-const search() + // or friends + dialogue = const_cast<ESM::Dialogue *>(mDialogs.search(id)); + assert (dialogue != NULL); + } else { + dialogue = 0; + } + // Insert the reference into the global lookup + if (!id.empty() && isCacheableRecord(n.val)) { + mIds[id] = n.val; + } + } + } + + /* This information isn't needed on screen. But keep the code around + for debugging purposes later. + + cout << "\n" << mStores.size() << " record types:\n"; + for(RecListList::iterator it = mStores.begin(); it != mStores.end(); it++) + cout << " " << toStr(it->first) << ": " << it->second->getSize() << endl; + cout << "\nNot implemented yet: "; + for(set<string>::iterator it = missing.begin(); + it != missing.end(); it++ ) + cout << *it << " "; + cout << endl; + */ +} + +void ESMStore::setUp() +{ + std::map<int, StoreBase *>::iterator it = mStores.begin(); + for (; it != mStores.end(); ++it) { + it->second->setUp(); + } + mSkills.setUp(); + mMagicEffects.setUp(); + mAttributes.setUp(); +} + +} // end namespace diff --git a/apps/openmw/mwworld/storedevel/esmstore.hpp b/apps/openmw/mwworld/storedevel/esmstore.hpp new file mode 100644 index 0000000000..525341a309 --- /dev/null +++ b/apps/openmw/mwworld/storedevel/esmstore.hpp @@ -0,0 +1,362 @@ +#ifndef OPENMW_MWWORLD_ESMSTORE_H +#define OPENMW_MWWORLD_ESMSTORE_H + +#include <stdexcept> + +#include <components/esm/records.hpp> +#include "store.hpp" + +namespace MWWorld +{ + class ESMStore + { + Store<ESM::Activator> mActivators; + Store<ESM::Potion> mPotions; + Store<ESM::Apparatus> mAppas; + Store<ESM::Armor> mArmors; + Store<ESM::BodyPart> mBodyParts; + Store<ESM::Book> mBooks; + Store<ESM::BirthSign> mBirthSigns; + Store<ESM::Class> mClasses; + Store<ESM::Clothing> mClothes; + Store<ESM::LoadCNTC> mContChange; + Store<ESM::Container> mContainers; + Store<ESM::Creature> mCreatures; + Store<ESM::LoadCREC> mCreaChange; + Store<ESM::Dialogue> mDialogs; + Store<ESM::Door> mDoors; + Store<ESM::Enchantment> mEnchants; + Store<ESM::Faction> mFactions; + Store<ESM::Global> mGlobals; + Store<ESM::Ingredient> mIngreds; + Store<ESM::CreatureLevList> mCreatureLists; + Store<ESM::ItemLevList> mItemLists; + Store<ESM::Light> mLights; + Store<ESM::Tool> mLockpicks; + Store<ESM::Miscellaneous> mMiscItems; + Store<ESM::NPC> mNpcs; + Store<ESM::LoadNPCC> mNpcChange; + Store<ESM::Probe> mProbes; + Store<ESM::Race> mRaces; + Store<ESM::Region> mRegions; + Store<ESM::Repair> mRepairs; + Store<ESM::SoundGenerator> mSoundGens; + Store<ESM::Sound> mSounds; + Store<ESM::Spell> mSpells; + Store<ESM::StartScript> mStartScripts; + Store<ESM::Static> mStatics; + Store<ESM::Weapon> mWeapons; + + Store<ESM::GameSetting> mGameSettings; + Store<ESM::Script> mScripts; + + // Lists that need special rules + Store<ESM::Cell> mCells; + Store<ESM::Land> mLands; + Store<ESM::LandTexture> mLandTextures; + Store<ESM::Pathgrid> mPathgrids; + + Store<ESM::MagicEffect> mMagicEffects; + Store<ESM::Skill> mSkills; + + // Special entry which is hardcoded and not loaded from an ESM + Store<ESM::Attribute> mAttributes; + + // Lookup of all IDs. Makes looking up references faster. Just + // maps the id name to the record type. + std::map<std::string, int> mIds; + std::map<int, StoreBase *> mStores; + + public: + // Look up the given ID in 'all'. Returns 0 if not found. + int find(const std::string &id) const + { + std::map<std::string, int>::const_iterator it = mIds.find(id); + if (it == mIds.end()) { + return 0; + } + return it->second; + } + + ESMStore() + { + mStores[ESM::REC_ACTI] = &mActivators; + mStores[ESM::REC_ALCH] = &mPotions; + mStores[ESM::REC_APPA] = &mAppas; + mStores[ESM::REC_ARMO] = &mArmors; + mStores[ESM::REC_BODY] = &mBodyParts; + mStores[ESM::REC_BOOK] = &mBooks; + mStores[ESM::REC_BSGN] = &mBirthSigns; + mStores[ESM::REC_CELL] = &mCells; + mStores[ESM::REC_CLAS] = &mClasses; + mStores[ESM::REC_CLOT] = &mClothes; + mStores[ESM::REC_CNTC] = &mContChange; + mStores[ESM::REC_CONT] = &mContainers; + mStores[ESM::REC_CREA] = &mCreatures; + mStores[ESM::REC_CREC] = &mCreaChange; + mStores[ESM::REC_DIAL] = &mDialogs; + mStores[ESM::REC_DOOR] = &mDoors; + mStores[ESM::REC_ENCH] = &mEnchants; + mStores[ESM::REC_FACT] = &mFactions; + mStores[ESM::REC_GLOB] = &mGlobals; + mStores[ESM::REC_GMST] = &mGameSettings; + mStores[ESM::REC_INGR] = &mIngreds; + mStores[ESM::REC_LAND] = &mLands; + mStores[ESM::REC_LEVC] = &mCreatureLists; + mStores[ESM::REC_LEVI] = &mItemLists; + mStores[ESM::REC_LIGH] = &mLights; + mStores[ESM::REC_LOCK] = &mLockpicks; + mStores[ESM::REC_LTEX] = &mLandTextures; + mStores[ESM::REC_MISC] = &mMiscItems; + mStores[ESM::REC_NPC_] = &mNpcs; + mStores[ESM::REC_NPCC] = &mNpcChange; + mStores[ESM::REC_PGRD] = &mPathgrids; + mStores[ESM::REC_PROB] = &mProbes; + mStores[ESM::REC_RACE] = &mRaces; + mStores[ESM::REC_REGN] = &mRegions; + mStores[ESM::REC_REPA] = &mRepairs; + mStores[ESM::REC_SCPT] = &mScripts; + mStores[ESM::REC_SNDG] = &mSoundGens; + mStores[ESM::REC_SOUN] = &mSounds; + mStores[ESM::REC_SPEL] = &mSpells; + mStores[ESM::REC_SSCR] = &mStartScripts; + mStores[ESM::REC_STAT] = &mStatics; + mStores[ESM::REC_WEAP] = &mWeapons; + } + + void load(ESM::ESMReader &esm); + void setUp(); + + template <class T> + const Store<T> &get() const { + throw std::runtime_error("Storage for this type not exist"); + } + }; + + template <> + const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { + return mActivators; + } + + template <> + const Store<ESM::Potion> &ESMStore::get<ESM::Potion>() const { + return mPotions; + } + + template <> + const Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() const { + return mAppas; + } + + template <> + const Store<ESM::Armor> &ESMStore::get<ESM::Armor>() const { + return mArmors; + } + + template <> + const Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() const { + return mBodyParts; + } + + template <> + const Store<ESM::Book> &ESMStore::get<ESM::Book>() const { + return mBooks; + } + + template <> + const Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() const { + return mBirthSigns; + } + + template <> + const Store<ESM::Class> &ESMStore::get<ESM::Class>() const { + return mClasses; + } + + template <> + const Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() const { + return mClothes; + } + + template <> + const Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() const { + return mContChange; + } + + template <> + const Store<ESM::Container> &ESMStore::get<ESM::Container>() const { + return mContainers; + } + + template <> + const Store<ESM::Creature> &ESMStore::get<ESM::Creature>() const { + return mCreatures; + } + + template <> + const Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() const { + return mCreaChange; + } + + template <> + const Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() const { + return mDialogs; + } + + template <> + const Store<ESM::Door> &ESMStore::get<ESM::Door>() const { + return mDoors; + } + + template <> + const Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() const { + return mEnchants; + } + + template <> + const Store<ESM::Faction> &ESMStore::get<ESM::Faction>() const { + return mFactions; + } + + template <> + const Store<ESM::Global> &ESMStore::get<ESM::Global>() const { + return mGlobals; + } + + template <> + const Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() const { + return mIngreds; + } + + template <> + const Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() const { + return mCreatureLists; + } + + template <> + const Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() const { + return mItemLists; + } + + template <> + const Store<ESM::Light> &ESMStore::get<ESM::Light>() const { + return mLights; + } + + template <> + const Store<ESM::Tool> &ESMStore::get<ESM::Tool>() const { + return mLockpicks; + } + + template <> + const Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() const { + return mMiscItems; + } + + template <> + const Store<ESM::NPC> &ESMStore::get<ESM::NPC>() const { + return mNpcs; + } + + template <> + const Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() const { + return mNpcChange; + } + + template <> + const Store<ESM::Probe> &ESMStore::get<ESM::Probe>() const { + return mProbes; + } + + template <> + const Store<ESM::Race> &ESMStore::get<ESM::Race>() const { + return mRaces; + } + + template <> + const Store<ESM::Region> &ESMStore::get<ESM::Region>() const { + return mRegions; + } + + template <> + const Store<ESM::Repair> &ESMStore::get<ESM::Repair>() const { + return mRepairs; + } + + template <> + const Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() const { + return mSoundGens; + } + + template <> + const Store<ESM::Sound> &ESMStore::get<ESM::Sound>() const { + return mSounds; + } + + template <> + const Store<ESM::Spell> &ESMStore::get<ESM::Spell>() const { + return mSpells; + } + + template <> + const Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() const { + return mStartScripts; + } + + template <> + const Store<ESM::Static> &ESMStore::get<ESM::Static>() const { + return mStatics; + } + + template <> + const Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() const { + return mWeapons; + } + + template <> + const Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() const { + return mGameSettings; + } + + template <> + const Store<ESM::Script> &ESMStore::get<ESM::Script>() const { + return mScripts; + } + + template <> + const Store<ESM::Cell> &ESMStore::get<ESM::Cell>() const { + return mCells; + } + + template <> + const Store<ESM::Land> &ESMStore::get<ESM::Land>() const { + return mLands; + } + + template <> + const Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() const { + return mLandTextures; + } + + template <> + const Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() const { + return mPathgrids; + } + + template <> + const Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() const { + return mMagicEffects; + } + + template <> + const Store<ESM::Skill> &ESMStore::get<ESM::Skill>() const { + return mSkills; + } + + template <> + const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { + return mAttributes; + } +} + +#endif From 9995fd324d334c758d38e1829e283913d4bfd9b6 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sat, 3 Nov 2012 20:20:16 +0400 Subject: [PATCH 120/255] split record comparator from store --- apps/openmw/mwworld/storedevel/recordcmp.hpp | 84 ++++++++ apps/openmw/mwworld/storedevel/store.hpp | 196 +++++-------------- 2 files changed, 132 insertions(+), 148 deletions(-) create mode 100644 apps/openmw/mwworld/storedevel/recordcmp.hpp diff --git a/apps/openmw/mwworld/storedevel/recordcmp.hpp b/apps/openmw/mwworld/storedevel/recordcmp.hpp new file mode 100644 index 0000000000..0e2871ba50 --- /dev/null +++ b/apps/openmw/mwworld/storedevel/recordcmp.hpp @@ -0,0 +1,84 @@ +#ifndef OPENMW_MWWORLD_RECORDCMP_H +#define OPENMW_MWWORLD_RECORDCMP_H + +#include <string> +#include <cctype> +#include <algorithm> + +#include <components/esm/records.hpp> + +namespace MWWorld +{ + /// \todo move this to another location + class StringUtils + { + struct ci + { + bool operator()(int x, int y) const { + return std::tolower(x) < std::tolower(y); + } + }; + + public: + static bool ciLess(const std::string &x, const std::string &y) { + return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end(), ci()); + } + + static bool ciEqual(const std::string &x, const std::string &y) { + if (x.size() != y.size()) { + return false; + } + std::string::const_iterator xit = x.begin(); + std::string::const_iterator yit = y.begin(); + for (; xit != x.end(); ++xit, ++yit) { + if (std::tolower(*xit) != std::tolower(*yit)) { + return false; + } + } + return true; + } + + /// Transforms input string to lower case w/o copy + static std::string &toLower(std::string &inout) { + std::transform( + inout.begin(), + inout.end(), + inout.begin(), + (int (*)(int)) std::tolower + ); + return inout; + } + + /// Returns lower case copy of input string + static std::string lowerCase(const std::string &in) + { + std::string out = in; + return toLower(out); + } + }; + + struct RecordCmp + { + template <class T> + bool operator()(const T &x, const T& y) const { + return x.mId < y.mId; + } + }; + + template <> + bool RecordCmp::operator()<ESM::Dialogue>(const ESM::Dialogue &x, const ESM::Dialogue &y) const { + return StringUtils::ciLess(x.mId, y.mId); + } + + template <> + bool RecordCmp::operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) const { + return StringUtils::ciLess(x.mName, y.mName); + } + + template <> + bool RecordCmp::operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &y) const { + return StringUtils::ciLess(x.mCell, y.mCell); + } + +} // end namespace +#endif diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index 14ff11e8a0..3a4a7960aa 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -1,97 +1,16 @@ #ifndef OPENMW_MWWORLD_STORE_H #define OPENMW_MWWORLD_STORE_H -#include <cctype> -#include <cassert> #include <string> #include <vector> -#include <algorithm> #include <stdexcept> +#include "recordcmp.hpp" + namespace MWWorld { - std::string lowerCase(const std::string &in) - { - std::string out = in; - std::transform( - in.begin(), - in.end(), - out.begin(), - (int (*)(int)) std::tolower - ); - - return out; - } - - struct CICompareString - { - struct ci - { - bool operator()(int x, int y) { - return std::tolower(x) < std::tolower(y); - } - }; - - bool operator()(const std::string &x, const std::string &y) { - return std::lexicographical_compare( - x.begin(), - x.end(), - y.begin(), - y.end(), - ci() - ); - } - }; - struct StoreBase { - class Compare - { - bool mCaseInsensitive; - - public: - Compare() - : mCaseInsensitive(false) - {} - - Compare(bool ci) - : mCaseInsensitive(ci) - {} - - Compare(const Compare &orig) - : mCaseInsensitive(orig.mCaseInsensitive) - {} - - template<class T> - bool operator()(const T &x, const T &y) { - if (mCaseInsensitive) { - return CICompareString()(x.mId, y.mId); - } - return x.mId < y.mId; - } - - bool isCaseInsensitive() const { - return mCaseInsensitive; - } - - bool equalString(const std::string &x, const std::string &y) const { - if (!mCaseInsensitive) { - return x == y; - } - if (x.length() != y.length()) { - return false; - } - std::string::const_iterator xit = x.begin(); - std::string::const_iterator yit = y.begin(); - for (; xit != x.end(); ++xit, ++yit) { - if (std::tolower(*xit) != std::tolower(*yit)) { - return false; - } - } - return true; - } - }; - virtual ~StoreBase() {} virtual void setUp() {} @@ -101,22 +20,6 @@ namespace MWWorld virtual void load(ESM::ESMReader &esm, const std::string &id) = 0; }; - template <> - bool StoreBase::Compare::operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) { - if (mCaseInsensitive) { - return CICompareString()(x.mName, y.mName); - } - return x.mName < y.mName; - } - - template <> - bool StoreBase::Compare::operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &y) { - if (mCaseInsensitive) { - return CICompareString()(x.mCell, y.mCell); - } - return x.mCell < y.mCell; - } - template <class T> class SharedIterator { @@ -179,33 +82,27 @@ namespace MWWorld template <class T> class Store : public StoreBase { - Compare mComp; std::vector<T> mData; std::vector<T *> mShared; public: Store() - : mComp(false) - {} - - Store(bool ci) - : mComp(ci) {} Store(const Store<T> &orig) - : mComp(orig.mComp), mData(orig.mData) + : mData(orig.mData) {} typedef SharedIterator<T> iterator; const T* search(const std::string &id) const { T item; - item.mId = lowerCase(id); + item.mId = StringUtils::lowerCase(id); typename std::vector<T>::const_iterator it = - std::lower_bound(mData.begin(), mData.end(), item, mComp); + std::lower_bound(mData.begin(), mData.end(), item, RecordCmp()); - if (it != mData.end() && mComp.equalString(it->mId, item.mId)) { + if (it != mData.end() && it->mId == item.mId) { return &(*it); } return 0; @@ -222,32 +119,13 @@ namespace MWWorld } void load(ESM::ESMReader &esm, const std::string &id) { - // reduce size of allocated memory to copy mData.push_back(T()); - - // some records requires id before loading - // make sure that string case is the same across container - if (mComp.isCaseInsensitive()) { - mData.back().mId = id; - } else { - mData.back().mId = lowerCase(id); - } + mData.back().mId = StringUtils::lowerCase(id); mData.back().load(esm); - - // allow records to overwrite id on loading - if (!mComp.isCaseInsensitive()) { - std::string &s = mData.back().mId; - std::transform( - s.begin(), - s.end(), - s.begin(), - (int (*)(int)) std::tolower - ); - } } void setUp() { - std::sort(mData.begin(), mData.end(), mComp); + std::sort(mData.begin(), mData.end(), RecordCmp()); mShared.reserve(mData.size()); typename std::vector<T>::iterator it = mData.begin(); @@ -277,6 +155,34 @@ namespace MWWorld } }; + template <> + void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id) { + mData.push_back(ESM::Dialogue()); + mData.back().mId = id; + mData.back().load(esm); + } + + template <> + const ESM::Dialogue *Store<ESM::Dialogue>::search(const std::string &id) const { + ESM::Dialogue item; + item.mId = id; + + std::vector<ESM::Dialogue>::const_iterator it = + std::lower_bound(mData.begin(), mData.end(), item, RecordCmp()); + + if (it != mData.end() && StringUtils::ciEqual(it->mId, id)) { + return &(*it); + } + return 0; + } + + template <> + void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id) { + mData.push_back(ESM::Script()); + mData.back().load(esm); + StringUtils::toLower(mData.back().mId); + } + template <> class Store<ESM::LandTexture> : public StoreBase { @@ -402,6 +308,7 @@ namespace MWWorld typedef std::vector<ESM::Cell>::const_iterator iterator; private: + struct ExtCompare { bool operator()(const ESM::Cell &x, const ESM::Cell &y) { @@ -425,24 +332,21 @@ namespace MWWorld } }; - Compare mIntCmp; std::vector<ESM::Cell> mData; std::vector<ESM::Cell>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; public: Store<ESM::Cell>() - : mIntCmp(true) {} - const ESM::Cell *search(const std::string &id) const { ESM::Cell cell; cell.mName = id; iterator it = - std::lower_bound(mIntBegin, mIntEnd, cell, mIntCmp); + std::lower_bound(mIntBegin, mIntEnd, cell, RecordCmp()); - if (it != mIntEnd && mIntCmp.equalString(it->mName, id)) { + if (it != mIntEnd && StringUtils::ciEqual(it->mName, id)) { return &(*it); } return 0; @@ -494,7 +398,7 @@ namespace MWWorld mIntBegin = mData.begin(); mIntEnd = mExtBegin; - std::sort(mIntBegin, mIntEnd, mIntCmp); + std::sort(mIntBegin, mIntEnd, RecordCmp()); std::sort(mExtBegin, mExtEnd, ExtCompare()); } @@ -531,7 +435,7 @@ namespace MWWorld /// \todo implement appropriate index const ESM::Cell *searchExteriorByName(const std::string &id) const { for (iterator it = mExtBegin; it != mExtEnd; ++it) { - if (mIntCmp.equalString(it->mName, id)) { + if (StringUtils::ciEqual(it->mName, id)) { return &(*it); } } @@ -541,7 +445,7 @@ namespace MWWorld /// \todo implement appropriate index const ESM::Cell *searchExteriorByRegion(const std::string &id) const { for (iterator it = mExtBegin; it != mExtEnd; ++it) { - if (mIntCmp.equalString(it->mRegion, id)) { + if (StringUtils::ciEqual(it->mRegion, id)) { return &(*it); } } @@ -567,7 +471,6 @@ namespace MWWorld typedef std::vector<ESM::Pathgrid>::const_iterator iterator; private: - Compare mIntCmp; std::vector<ESM::Pathgrid> mData; std::vector<ESM::Pathgrid>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; @@ -595,9 +498,6 @@ namespace MWWorld }; public: - Store<ESM::Pathgrid>() - : mIntCmp(true) - {} void load(ESM::ESMReader &esm, const std::string &id) { mData.push_back(ESM::Pathgrid()); @@ -621,7 +521,7 @@ namespace MWWorld mIntBegin = mData.begin(); mIntEnd = mExtBegin; - std::sort(mIntBegin, mIntEnd, mIntCmp); + std::sort(mIntBegin, mIntEnd, RecordCmp()); std::sort(mExtBegin, mExtEnd, ExtCompare()); } @@ -652,8 +552,8 @@ namespace MWWorld ESM::Pathgrid pg; pg.mCell = name; - iterator it = std::lower_bound(mIntBegin, mIntEnd, pg, mIntCmp); - if (it != mIntEnd && mIntCmp.equalString(it->mCell, name)) { + iterator it = std::lower_bound(mIntBegin, mIntEnd, pg, RecordCmp()); + if (it != mIntEnd && StringUtils::ciEqual(it->mCell, name)) { return &(*it); } return 0; @@ -804,14 +704,14 @@ namespace MWWorld mData.reserve(ESM::Attribute::Length); } - const ESM::Attribute *search(int index) const { - if (index < 0 || index >= mData.size()) { + const ESM::Attribute *search(size_t index) const { + if (index >= mData.size()) { return 0; } return &mData.at(index); } - const ESM::Attribute *find(int index) const { + const ESM::Attribute *find(size_t index) const { const ESM::Attribute *ptr = search(index); if (ptr == 0) { std::ostringstream msg; From 0f524e4a6097a5739637a5b75cc88f0b18834a2d Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 01:23:43 +0400 Subject: [PATCH 121/255] dynamic storage for records with string id --- apps/openmw/mwworld/storedevel/store.hpp | 244 ++++++++++++++--------- 1 file changed, 146 insertions(+), 98 deletions(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index 3a4a7960aa..de80e99506 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -3,6 +3,7 @@ #include <string> #include <vector> +#include <map> #include <stdexcept> #include "recordcmp.hpp" @@ -82,27 +83,35 @@ namespace MWWorld template <class T> class Store : public StoreBase { - std::vector<T> mData; + std::vector<T> mStatic; std::vector<T *> mShared; + std::map<std::string, T> mDynamic; + + typedef std::map<std::string, T> Dynamic; public: Store() {} Store(const Store<T> &orig) - : mData(orig.mData) + : mStatic(orig.mData) {} typedef SharedIterator<T> iterator; - const T* search(const std::string &id) const { + const T *search(const std::string &id) const { T item; item.mId = StringUtils::lowerCase(id); - typename std::vector<T>::const_iterator it = - std::lower_bound(mData.begin(), mData.end(), item, RecordCmp()); + typename Dynamic::const_iterator dit = mDynamic.find(item.mId); + if (dit != mDynamic.end()) { + return &dit->second; + } - if (it != mData.end() && it->mId == item.mId) { + typename std::vector<T>::const_iterator it = + std::lower_bound(mStatic.begin(), mStatic.end(), item, RecordCmp()); + + if (it != mStatic.end() && it->mId == item.mId) { return &(*it); } return 0; @@ -112,33 +121,33 @@ namespace MWWorld const T *ptr = search(id); if (ptr == 0) { std::ostringstream msg; - msg << "Object '" << id << "' not found"; + msg << "Object '" << id << "' not found (const)"; throw std::runtime_error(msg.str()); } return ptr; } void load(ESM::ESMReader &esm, const std::string &id) { - mData.push_back(T()); - mData.back().mId = StringUtils::lowerCase(id); - mData.back().load(esm); + mStatic.push_back(T()); + mStatic.back().mId = StringUtils::lowerCase(id); + mStatic.back().load(esm); } void setUp() { - std::sort(mData.begin(), mData.end(), RecordCmp()); + std::sort(mStatic.begin(), mStatic.end(), RecordCmp()); - mShared.reserve(mData.size()); - typename std::vector<T>::iterator it = mData.begin(); - for (; it != mData.end(); ++it) { + mShared.reserve(mStatic.size()); + typename std::vector<T>::iterator it = mStatic.begin(); + for (; it != mStatic.end(); ++it) { mShared.push_back(&(*it)); } } - iterator begin() { + iterator begin() const { return mShared.begin(); } - iterator end() { + iterator end() const { return mShared.end(); } @@ -153,51 +162,90 @@ namespace MWWorld list.push_back((*it)->mId); } } + + T *search(const std::string &id) { + std::string key = StringUtils::lowerCase(id); + typename Dynamic::iterator dit = mDynamic.find(key); + + if (dit != mDynamic.end()) { + return &dit->second; + } + return 0; + } + + T *find(const std::string &id) { + T *ptr = search(id); + if (ptr == 0) { + std::ostringstream msg; + msg << "Object '" << id << "' not found (non-const)"; + throw std::runtime_error(msg.str()); + } + return ptr; + } + + T *insert(const T &item) { + std::string id = StringUtils::lowerCase(item.mId); + std::pair<typename Dynamic::iterator, bool> result = + mDynamic.insert(std::pair<std::string, T>(id, item)); + T *ptr = &result.first->second; + if (result.second) { + mShared.push_back(ptr); + } else { + *ptr = item; + } + return ptr; + } + + bool erase(const std::string &id) { + std::string key = StringUtils::lowerCase(id); + typename Dynamic::iterator it = mDynamic.find(key); + if (it == mDynamic.end()) { + return false; + } + mDynamic.erase(it); + + // have to reinit the whole shared part + mShared.erase(mShared.begin() + mStatic.size(), mShared.end()); + for (it = mDynamic.begin(); it != mDynamic.end(); ++it) { + mShared.push_back(&it->second); + } + return true; + } + + bool erase(const T &item) { + return erase(item.mId); + } }; template <> void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id) { - mData.push_back(ESM::Dialogue()); - mData.back().mId = id; - mData.back().load(esm); - } - - template <> - const ESM::Dialogue *Store<ESM::Dialogue>::search(const std::string &id) const { - ESM::Dialogue item; - item.mId = id; - - std::vector<ESM::Dialogue>::const_iterator it = - std::lower_bound(mData.begin(), mData.end(), item, RecordCmp()); - - if (it != mData.end() && StringUtils::ciEqual(it->mId, id)) { - return &(*it); - } - return 0; + mStatic.push_back(ESM::Dialogue()); + mStatic.back().mId = id; + mStatic.back().load(esm); } template <> void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id) { - mData.push_back(ESM::Script()); - mData.back().load(esm); - StringUtils::toLower(mData.back().mId); + mStatic.push_back(ESM::Script()); + mStatic.back().load(esm); + StringUtils::toLower(mStatic.back().mId); } template <> class Store<ESM::LandTexture> : public StoreBase { - std::vector<ESM::LandTexture> mData; + std::vector<ESM::LandTexture> mStatic; public: Store<ESM::LandTexture>() { - mData.reserve(128); + mStatic.reserve(128); } typedef std::vector<ESM::LandTexture>::const_iterator iterator; const ESM::LandTexture *search(size_t index) const { - if (index < mData.size()) { - return &mData.at(index); + if (index < mStatic.size()) { + return &mStatic.at(index); } return 0; } @@ -213,33 +261,33 @@ namespace MWWorld } int getSize() const { - return mData.size(); + return mStatic.size(); } void load(ESM::ESMReader &esm, const std::string &id) { ESM::LandTexture ltex; ltex.load(esm); - if (ltex.mIndex >= (int) mData.size()) { - mData.resize(ltex.mIndex + 1); + if (ltex.mIndex >= (int) mStatic.size()) { + mStatic.resize(ltex.mIndex + 1); } - mData[ltex.mIndex] = ltex; - mData[ltex.mIndex].mId = id; + mStatic[ltex.mIndex] = ltex; + mStatic[ltex.mIndex].mId = id; } - iterator begin() { - return mData.begin(); + iterator begin() const { + return mStatic.begin(); } - iterator end() { - return mData.end(); + iterator end() const { + return mStatic.end(); } }; template <> class Store<ESM::Land> : public StoreBase { - std::vector<ESM::Land *> mData; + std::vector<ESM::Land *> mStatic; struct Compare { @@ -255,15 +303,15 @@ namespace MWWorld typedef SharedIterator<ESM::Land> iterator; int getSize() const { - return mData.size(); + return mStatic.size(); } - iterator begin() { - return iterator(mData.begin()); + iterator begin() const { + return iterator(mStatic.begin()); } - iterator end() { - return iterator(mData.end()); + iterator end() const { + return iterator(mStatic.end()); } ESM::Land *search(int x, int y) { @@ -271,9 +319,9 @@ namespace MWWorld land.mX = x, land.mY = y; std::vector<ESM::Land *>::iterator it = - std::lower_bound(mData.begin(), mData.end(), &land, Compare()); + std::lower_bound(mStatic.begin(), mStatic.end(), &land, Compare()); - if (it != mData.end() && (*it)->mX == x && (*it)->mY == y) { + if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) { return *it; } return 0; @@ -293,11 +341,11 @@ namespace MWWorld ESM::Land *ptr = new ESM::Land(); ptr->load(esm); - mData.push_back(ptr); + mStatic.push_back(ptr); } void setUp() { - std::sort(mData.begin(), mData.end(), Compare()); + std::sort(mStatic.begin(), mStatic.end(), Compare()); } }; @@ -332,7 +380,7 @@ namespace MWWorld } }; - std::vector<ESM::Cell> mData; + std::vector<ESM::Cell> mStatic; std::vector<ESM::Cell>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; public: @@ -387,15 +435,15 @@ namespace MWWorld void setUp() { IntExtOrdering cmp; - std::sort(mData.begin(), mData.end(), cmp); + std::sort(mStatic.begin(), mStatic.end(), cmp); ESM::Cell cell; cell.mData.mFlags = 0; mExtBegin = - std::lower_bound(mData.begin(), mData.end(), cell, cmp); - mExtEnd = mData.end(); + std::lower_bound(mStatic.begin(), mStatic.end(), cell, cmp); + mExtEnd = mStatic.end(); - mIntBegin = mData.begin(); + mIntBegin = mStatic.begin(); mIntEnd = mExtBegin; std::sort(mIntBegin, mIntEnd, RecordCmp()); @@ -403,17 +451,17 @@ namespace MWWorld } void load(ESM::ESMReader &esm, const std::string &id) { - mData.push_back(ESM::Cell()); - mData.back().mName = id; - mData.back().load(esm); + mStatic.push_back(ESM::Cell()); + mStatic.back().mName = id; + mStatic.back().load(esm); } iterator begin() const { - return mData.begin(); + return mStatic.begin(); } iterator end() const { - return mData.end(); + return mStatic.end(); } iterator interiorsBegin() const { @@ -453,7 +501,7 @@ namespace MWWorld } int getSize() const { - return mData.size(); + return mStatic.size(); } void listIdentifier(std::vector<std::string> &list) const { @@ -471,7 +519,7 @@ namespace MWWorld typedef std::vector<ESM::Pathgrid>::const_iterator iterator; private: - std::vector<ESM::Pathgrid> mData; + std::vector<ESM::Pathgrid> mStatic; std::vector<ESM::Pathgrid>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; @@ -500,25 +548,25 @@ namespace MWWorld public: void load(ESM::ESMReader &esm, const std::string &id) { - mData.push_back(ESM::Pathgrid()); - mData.back().load(esm); + mStatic.push_back(ESM::Pathgrid()); + mStatic.back().load(esm); } int getSize() const { - return mData.size(); + return mStatic.size(); } void setUp() { IntExtOrdering cmp; - std::sort(mData.begin(), mData.end(), cmp); + std::sort(mStatic.begin(), mStatic.end(), cmp); ESM::Pathgrid pg; pg.mData.mX = pg.mData.mY = 1; mExtBegin = - std::lower_bound(mData.begin(), mData.end(), pg, cmp); - mExtEnd = mData.end(); + std::lower_bound(mStatic.begin(), mStatic.end(), pg, cmp); + mExtEnd = mStatic.end(); - mIntBegin = mData.begin(); + mIntBegin = mStatic.begin(); mIntEnd = mExtBegin; std::sort(mIntBegin, mIntEnd, RecordCmp()); @@ -584,11 +632,11 @@ namespace MWWorld } iterator begin() const { - return mData.begin(); + return mStatic.begin(); } iterator end() const { - return mData.end(); + return mStatic.end(); } iterator interiorPathsBegin() const { @@ -618,7 +666,7 @@ namespace MWWorld } }; protected: - std::vector<T> mData; + std::vector<T> mStatic; public: typedef typename std::vector<T>::const_iterator iterator; @@ -626,29 +674,29 @@ namespace MWWorld IndexedStore() {} IndexedStore(unsigned int size) { - mData.reserve(size); + mStatic.reserve(size); } iterator begin() const { - return mData.begin(); + return mStatic.begin(); } iterator end() const { - return mData.end(); + return mStatic.end(); } /// \todo refine loading order void load(ESM::ESMReader &esm) { - mData.push_back(T()); - mData.back().load(esm); + mStatic.push_back(T()); + mStatic.back().load(esm); } int getSize() const { - return mData.size(); + return mStatic.size(); } void setUp() { - std::sort(mData.begin(), mData.end(), Compare()); + std::sort(mStatic.begin(), mStatic.end(), Compare()); } const T *search(int index) const { @@ -656,8 +704,8 @@ namespace MWWorld item.mIndex = index; iterator it = - std::lower_bound(mData.begin(), mData.end(), item, Compare()); - if (it != mData.end() && it->mIndex == index) { + std::lower_bound(mStatic.begin(), mStatic.end(), item, Compare()); + if (it != mStatic.end() && it->mIndex == index) { return &(*it); } return 0; @@ -695,20 +743,20 @@ namespace MWWorld template <> class Store<ESM::Attribute> : public IndexedStore<ESM::Attribute> { - std::vector<ESM::Attribute> mData; + std::vector<ESM::Attribute> mStatic; public: typedef std::vector<ESM::Attribute>::const_iterator iterator; Store() { - mData.reserve(ESM::Attribute::Length); + mStatic.reserve(ESM::Attribute::Length); } const ESM::Attribute *search(size_t index) const { - if (index >= mData.size()) { + if (index >= mStatic.size()) { return 0; } - return &mData.at(index); + return &mStatic.at(index); } const ESM::Attribute *find(size_t index) const { @@ -723,7 +771,7 @@ namespace MWWorld void setUp() { for (int i = 0; i < ESM::Attribute::Length; ++i) { - mData.push_back( + mStatic.push_back( ESM::Attribute( ESM::Attribute::sAttributeIds[i], ESM::Attribute::sGmstAttributeIds[i], @@ -734,15 +782,15 @@ namespace MWWorld } int getSize() const { - return mData.size(); + return mStatic.size(); } iterator begin() const { - return mData.begin(); + return mStatic.begin(); } iterator end() const { - return mData.end(); + return mStatic.end(); } }; From 10ae5d33653e7012d6f0a661c874b8e09e89573d Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 12:11:53 +0400 Subject: [PATCH 122/255] dynamic storage for cells --- apps/openmw/mwworld/storedevel/store.hpp | 260 +++++++++++++++++------ 1 file changed, 196 insertions(+), 64 deletions(-) diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/storedevel/store.hpp index de80e99506..8f88a16a71 100644 --- a/apps/openmw/mwworld/storedevel/store.hpp +++ b/apps/openmw/mwworld/storedevel/store.hpp @@ -352,12 +352,7 @@ namespace MWWorld template <> class Store<ESM::Cell> : public StoreBase { - public: - typedef std::vector<ESM::Cell>::const_iterator iterator; - - private: - - struct ExtCompare + struct ExtCmp { bool operator()(const ESM::Cell &x, const ESM::Cell &y) { if (x.mData.mX == y.mData.mX) { @@ -367,34 +362,45 @@ namespace MWWorld } }; - struct IntExtOrdering - { - bool operator()(const ESM::Cell &x, const ESM::Cell &y) { - // interiors precedes exteriors (x < y) - if ((x.mData.mFlags & ESM::Cell::Interior) != 0 && - (y.mData.mFlags & ESM::Cell::Interior) == 0) - { - return true; - } - return false; - } - }; + std::vector<ESM::Cell> mInt; + std::vector<ESM::Cell> mExt; - std::vector<ESM::Cell> mStatic; - std::vector<ESM::Cell>::iterator mIntBegin, mIntEnd, mExtBegin, mExtEnd; + std::vector<ESM::Cell *> mSharedInt; + std::vector<ESM::Cell *> mSharedExt; + + typedef std::map<std::string, ESM::Cell> DynamicInt; + typedef std::map<std::pair<int, int>, ESM::Cell> DynamicExt; + + DynamicInt mDynamicInt; + DynamicExt mDynamicExt; + + + const ESM::Cell *search(const ESM::Cell &cell) const { + if (cell.isExterior()) { + return search(cell.getGridX(), cell.getGridY()); + } + return search(cell.mName); + } public: + typedef SharedIterator<ESM::Cell> iterator; + Store<ESM::Cell>() {} const ESM::Cell *search(const std::string &id) const { ESM::Cell cell; - cell.mName = id; + cell.mName = StringUtils::lowerCase(id); - iterator it = - std::lower_bound(mIntBegin, mIntEnd, cell, RecordCmp()); + DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName); + if (dit != mDynamicInt.end()) { + return &dit->second; + } - if (it != mIntEnd && StringUtils::ciEqual(it->mName, id)) { + std::vector<ESM::Cell>::const_iterator it = + std::lower_bound(mInt.begin(), mInt.end(), cell, RecordCmp()); + + if (it != mInt.end() && StringUtils::ciEqual(it->mName, id)) { return &(*it); } return 0; @@ -404,10 +410,16 @@ namespace MWWorld ESM::Cell cell; cell.mData.mX = x, cell.mData.mY = y; - iterator it = - std::lower_bound(mExtBegin, mExtEnd, cell, ExtCompare()); + std::pair<int, int> key(x, y); + DynamicExt::const_iterator dit = mDynamicExt.find(key); + if (dit != mDynamicExt.end()) { + return &dit->second; + } - if (it != mExtEnd && it->mData.mX == x && it->mData.mY == y) { + std::vector<ESM::Cell>::const_iterator it = + std::lower_bound(mExt.begin(), mExt.end(), cell, ExtCmp()); + + if (it != mExt.end() && it->mData.mX == x && it->mData.mY == y) { return &(*it); } return 0; @@ -434,57 +446,55 @@ namespace MWWorld } void setUp() { - IntExtOrdering cmp; - std::sort(mStatic.begin(), mStatic.end(), cmp); + typedef std::vector<ESM::Cell>::iterator Iterator; - ESM::Cell cell; - cell.mData.mFlags = 0; - mExtBegin = - std::lower_bound(mStatic.begin(), mStatic.end(), cell, cmp); - mExtEnd = mStatic.end(); + std::sort(mInt.begin(), mInt.end(), RecordCmp()); + mSharedInt.reserve(mInt.size()); + for (Iterator it = mInt.begin(); it != mInt.end(); ++it) { + mSharedInt.push_back(&(*it)); + } - mIntBegin = mStatic.begin(); - mIntEnd = mExtBegin; - - std::sort(mIntBegin, mIntEnd, RecordCmp()); - std::sort(mExtBegin, mExtEnd, ExtCompare()); + std::sort(mExt.begin(), mExt.end(), ExtCmp()); + mSharedExt.reserve(mExt.size()); + for (Iterator it = mExt.begin(); it != mExt.end(); ++it) { + mSharedExt.push_back(&(*it)); + } } void load(ESM::ESMReader &esm, const std::string &id) { - mStatic.push_back(ESM::Cell()); - mStatic.back().mName = id; - mStatic.back().load(esm); - } + ESM::Cell cell; + cell.mName = id; + cell.load(esm); - iterator begin() const { - return mStatic.begin(); - } - - iterator end() const { - return mStatic.end(); + if (cell.isExterior()) { + mExt.push_back(cell); + } else { + mInt.push_back(cell); + } } iterator interiorsBegin() const { - return mIntBegin; + return iterator(mSharedInt.begin()); } iterator interiorsEnd() const { - return mIntEnd; + return iterator(mSharedInt.end()); } iterator exteriorsBegin() const { - return mExtBegin; + return iterator(mSharedExt.begin()); } iterator exteriorsEnd() const { - return mExtEnd; + return iterator(mSharedExt.end()); } /// \todo implement appropriate index const ESM::Cell *searchExteriorByName(const std::string &id) const { - for (iterator it = mExtBegin; it != mExtEnd; ++it) { - if (StringUtils::ciEqual(it->mName, id)) { - return &(*it); + std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin(); + for (; it != mSharedExt.end(); ++it) { + if (StringUtils::ciEqual((*it)->mName, id)) { + return *it; } } return 0; @@ -492,24 +502,145 @@ namespace MWWorld /// \todo implement appropriate index const ESM::Cell *searchExteriorByRegion(const std::string &id) const { - for (iterator it = mExtBegin; it != mExtEnd; ++it) { - if (StringUtils::ciEqual(it->mRegion, id)) { - return &(*it); + std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin(); + for (; it != mSharedExt.end(); ++it) { + if (StringUtils::ciEqual((*it)->mRegion, id)) { + return *it; } } return 0; } int getSize() const { - return mStatic.size(); + return mSharedInt.size() + mSharedExt.size(); } void listIdentifier(std::vector<std::string> &list) const { - list.reserve(list.size() + (mIntEnd - mIntBegin)); - for (iterator it = mIntBegin; it != mIntEnd; ++it) { - list.push_back(it->mName); + list.reserve(list.size() + mSharedInt.size()); + + std::vector<ESM::Cell *>::const_iterator it = mSharedInt.begin(); + for (; it != mSharedInt.end(); ++it) { + list.push_back((*it)->mName); } } + + ESM::Cell *search(const std::string &id) { + std::string key = StringUtils::lowerCase(id); + DynamicInt::iterator it = mDynamicInt.find(key); + if (it != mDynamicInt.end()) { + return &it->second; + } + return 0; + } + + ESM::Cell *find(const std::string &id) { + ESM::Cell *ptr = search(id); + if (ptr == 0) { + std::ostringstream msg; + msg << "Interior '" << id << "' not found (non-const)"; + throw std::runtime_error(msg.str()); + } + return ptr; + } + + ESM::Cell *search(int x, int y) { + DynamicExt::iterator it = mDynamicExt.find(std::make_pair(x, y)); + if (it != mDynamicExt.end()) { + return &it->second; + } + return 0; + } + + ESM::Cell *find(int x, int y) { + ESM::Cell *ptr = search(x, y); + if (ptr == 0) { + std::ostringstream msg; + msg << "Exterior at (" << x << ", " << y << ") not found (non-const"; + throw std::runtime_error(msg.str()); + } + return ptr; + } + + ESM::Cell *insert(const ESM::Cell &cell) { + if (search(cell) != 0) { + std::ostringstream msg; + msg << "Failed to create "; + msg << ((cell.isExterior()) ? "exterior" : "interior"); + msg << " cell"; + + throw std::runtime_error(msg.str()); + } + ESM::Cell *ptr; + if (cell.isExterior()) { + std::pair<int, int> key(cell.getGridX(), cell.getGridY()); + DynamicExt::iterator it = mDynamicExt.find(key); + + // duplicate insertions are avoided by search(ESM::Cell &) + std::pair<DynamicExt::iterator, bool> result = + mDynamicExt.insert(std::make_pair(key, cell)); + + ptr = &result.first->second; + mSharedExt.push_back(ptr); + } else { + std::string key = StringUtils::lowerCase(cell.mName); + DynamicInt::iterator it = mDynamicInt.find(key); + + // duplicate insertions are avoided by search(ESM::Cell &) + std::pair<DynamicInt::iterator, bool> result = + mDynamicInt.insert(std::make_pair(key, cell)); + + ptr = &result.first->second; + mSharedInt.push_back(ptr); + } + return ptr; + } + + bool erase(const ESM::Cell &cell) { + if (cell.isExterior()) { + return erase(cell.getGridX(), cell.getGridY()); + } + return erase(cell.mName); + } + + bool erase(const std::string &id) { + std::string key = StringUtils::lowerCase(id); + DynamicInt::iterator it = mDynamicInt.find(key); + + if (it == mDynamicInt.end()) { + return false; + } + mDynamicInt.erase(it); + mSharedInt.erase( + mSharedInt.begin() + mSharedInt.size(), + mSharedInt.end() + ); + + for (it = mDynamicInt.begin(); it != mDynamicInt.end(); ++it) { + mSharedInt.push_back(&it->second); + } + + return true; + } + + bool erase(int x, int y) { + std::pair<int, int> key(x, y); + DynamicExt::iterator it = mDynamicExt.find(key); + + if (it == mDynamicExt.end()) { + return false; + } + mDynamicExt.erase(it); + mSharedExt.erase( + mSharedExt.begin() + mSharedExt.size(), + mSharedExt.end() + ); + + for (it = mDynamicExt.begin(); it != mDynamicExt.end(); ++it) { + mSharedExt.push_back(&it->second); + } + + return true; + } }; template <> @@ -530,8 +661,9 @@ namespace MWWorld if ((x.mData.mX == 0 && x.mData.mY == 0) && (y.mData.mX != 0 || y.mData.mY != 0)) { - return false; + return true; } + return false; } }; From 8691eac55732a278d54328d250e4056c969e0898 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 17:41:36 +0400 Subject: [PATCH 123/255] resolve Script::mData.mName -> mId, resolve moving ESMStore --- apps/esmtool/record.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.cpp | 3 +-- apps/openmw/mwmechanics/alchemy.cpp | 4 ++-- apps/openmw/mwworld/reclists.hpp | 2 +- components/esm/loadscpt.cpp | 4 ++-- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index 856700f5e3..e26015970e 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -1213,7 +1213,7 @@ void Record<ESM::Region>::print() template<> void Record<ESM::Script>::print() { - std::cout << " Name: " << mData.mData.mName.toString() << std::endl; + std::cout << " Name: " << mData.mId << std::endl; std::cout << " Num Shorts: " << mData.mData.mNumShorts << std::endl; std::cout << " Num Longs: " << mData.mData.mNumLongs << std::endl; diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 4ce0560108..6c45d2b3d9 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -2,14 +2,13 @@ #include <boost/lexical_cast.hpp> -#include <components/esm_store/store.hpp> - #include "../mwbase/windowmanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwworld/esmstore.hpp" #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 962350472e..99259bad18 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -13,11 +13,11 @@ #include <components/esm/loadgmst.hpp> #include <components/esm/loadmgef.hpp> -#include <components/esm_store/store.hpp> #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwworld/esmstore.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/class.hpp" #include "../mwworld/cellstore.hpp" @@ -192,7 +192,7 @@ void MWMechanics::Alchemy::updateEffects() const ESM::Potion *MWMechanics::Alchemy::getRecord() const { - for (ESMS::RecListWithIDT<ESM::Potion>::MapType::const_iterator iter ( + for (MWWorld::RecListWithIDT<ESM::Potion>::MapType::const_iterator iter ( MWBase::Environment::get().getWorld()->getStore().potions.list.begin()); iter!=MWBase::Environment::get().getWorld()->getStore().potions.list.end(); ++iter) { diff --git a/apps/openmw/mwworld/reclists.hpp b/apps/openmw/mwworld/reclists.hpp index 1548049ae8..179a7ac7c1 100644 --- a/apps/openmw/mwworld/reclists.hpp +++ b/apps/openmw/mwworld/reclists.hpp @@ -528,7 +528,7 @@ namespace MWWorld X ref; ref.load (esm); - std::string realId = toLower (ref.mData.mName.toString()); + std::string realId = toLower (ref.mId); std::swap (list[realId], ref); } diff --git a/components/esm/loadscpt.cpp b/components/esm/loadscpt.cpp index 55a71b6b7f..d9b6497d98 100644 --- a/components/esm/loadscpt.cpp +++ b/components/esm/loadscpt.cpp @@ -8,8 +8,8 @@ namespace ESM struct SCHD { - NAME32 mName; - SCHDstruct mData; + NAME32 mName; + Script::SCHDstruct mData; }; void Script::load(ESMReader &esm) From 7cf0b8a680e7a88a82c2863050c8ab972dedbc20 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 18:09:14 +0400 Subject: [PATCH 124/255] just replace esmstore, inconsistent --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwworld/esmstore.cpp | 108 ++- apps/openmw/mwworld/esmstore.hpp | 479 ++++++++++---- apps/openmw/mwworld/reclists.hpp | 620 ------------------ .../mwworld/{storedevel => }/recordcmp.hpp | 0 .../openmw/mwworld/{storedevel => }/store.hpp | 0 apps/openmw/mwworld/storedevel/esmstore.cpp | 100 --- apps/openmw/mwworld/storedevel/esmstore.hpp | 362 ---------- 8 files changed, 398 insertions(+), 1273 deletions(-) delete mode 100644 apps/openmw/mwworld/reclists.hpp rename apps/openmw/mwworld/{storedevel => }/recordcmp.hpp (100%) rename apps/openmw/mwworld/{storedevel => }/store.hpp (100%) delete mode 100644 apps/openmw/mwworld/storedevel/esmstore.cpp delete mode 100644 apps/openmw/mwworld/storedevel/esmstore.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 07d27553de..b9ce26a661 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -53,7 +53,7 @@ add_openmw_dir (mwworld containerstore actiontalk actiontake manualref player cellfunctors cells localscripts customdata weather inventorystore ptr actionopen actionread actionequip timestamp actionalchemy cellstore actionapply actioneat - esmstore reclists + esmstore store recordcmp ) add_openmw_dir (mwclass diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index c145fb3da1..eb236d1bc2 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -6,6 +6,19 @@ namespace MWWorld { +static bool isCacheableRecord(int id) +{ + if (id == ESM::REC_ACTI || id == ESM::REC_ALCH || id == ESM::REC_APPA || id == ESM::REC_ARMO || + id == ESM::REC_BOOK || id == ESM::REC_CLOT || id == ESM::REC_CONT || id == ESM::REC_CREA || + id == ESM::REC_DOOR || id == ESM::REC_INGR || id == ESM::REC_LEVC || id == ESM::REC_LEVI || + id == ESM::REC_LIGH || id == ESM::REC_LOCK || id == ESM::REC_MISC || id == ESM::REC_NPC_ || + id == ESM::REC_PROB || id == ESM::REC_REPA || id == ESM::REC_STAT || id == ESM::REC_WEAP) + { + return true; + } + return false; +} + void ESMStore::load(ESM::ESMReader &esm) { std::set<std::string> missing; @@ -19,85 +32,51 @@ void ESMStore::load(ESM::ESMReader &esm) esm.getRecHeader(); // Look up the record type. - RecListList::iterator it = recLists.find(n.val); + std::map<int, StoreBase *>::iterator it = mStores.find(n.val); - if(it == recLists.end()) - { - if (n.val==ESM::REC_INFO) - { - if (dialogue) - { - ESM::DialInfo info; - info.load (esm); - - dialogue->mInfo.push_back (info); - } - else - { + if (it == mStores.end()) { + if (n.val == ESM::REC_INFO) { + if (dialogue) { + dialogue->mInfo.push_back(ESM::DialInfo()); + dialogue->mInfo.back().load(esm); + } else { std::cerr << "error: info record without dialog" << std::endl; esm.skipRecord(); } - } - else if (n.val==ESM::REC_MGEF) - { - magicEffects.load (esm); - } - else if (n.val==ESM::REC_SKIL) - { - skills.load (esm); - } - else - { + } else if (n.val == ESM::REC_MGEF) { + mMagicEffects.load (esm); + } else if (n.val == ESM::REC_SKIL) { + mSkills.load (esm); + } else { // Not found (this would be an error later) esm.skipRecord(); missing.insert(n.toString()); } - } - else - { + } else { // Load it std::string id = esm.getHNOString("NAME"); it->second->load(esm, id); - if (n.val==ESM::REC_DIAL) - { - RecListCaseT<ESM::Dialogue>& recList = - static_cast<RecListCaseT<ESM::Dialogue>& > (*it->second); - - ESM::Dialogue* d = recList.search (id); - - assert (d != NULL); - - dialogue = d; - } - else + if (n.val==ESM::REC_DIAL) { + // dirty hack, but it is better than non-const search() + // or friends + dialogue = const_cast<ESM::Dialogue *>(mDialogs.search(id)); + assert (dialogue != NULL); + } else { dialogue = 0; - + } // Insert the reference into the global lookup - if(!id.empty() && - (n.val==ESM::REC_ACTI || n.val==ESM::REC_ALCH || n.val==ESM::REC_APPA || n.val==ESM::REC_ARMO || - n.val==ESM::REC_BOOK || n.val==ESM::REC_CLOT || n.val==ESM::REC_CONT || n.val==ESM::REC_CREA || - n.val==ESM::REC_DOOR || n.val==ESM::REC_INGR || n.val==ESM::REC_LEVC || n.val==ESM::REC_LEVI || - n.val==ESM::REC_LIGH || n.val==ESM::REC_LOCK || n.val==ESM::REC_MISC || n.val==ESM::REC_NPC_ || - n.val==ESM::REC_PROB || n.val==ESM::REC_REPA || n.val==ESM::REC_STAT || n.val==ESM::REC_WEAP) - ) - all[id] = n.val; + if (!id.empty() && isCacheableRecord(n.val)) { + mIds[id] = n.val; + } } } - for (int i = 0; i < ESM::Attribute::Length; ++i) - { - typedef ESM::Attribute EsmAttr; - - EsmAttr::AttributeID id = EsmAttr::sAttributeIds[i]; - attributes.list.insert(std::make_pair(id, ESM::Attribute(id, EsmAttr::sGmstAttributeIds[i], EsmAttr::sGmstAttributeDescIds[i]))); - } - /* This information isn't needed on screen. But keep the code around for debugging purposes later. - cout << "\n" << recLists.size() << " record types:\n"; - for(RecListList::iterator it = recLists.begin(); it != recLists.end(); it++) + cout << "\n" << mStores.size() << " record types:\n"; + for(RecListList::iterator it = mStores.begin(); it != mStores.end(); it++) cout << " " << toStr(it->first) << ": " << it->second->getSize() << endl; cout << "\nNot implemented yet: "; for(set<string>::iterator it = missing.begin(); @@ -107,4 +86,15 @@ void ESMStore::load(ESM::ESMReader &esm) */ } +void ESMStore::setUp() +{ + std::map<int, StoreBase *>::iterator it = mStores.begin(); + for (; it != mStores.end(); ++it) { + it->second->setUp(); + } + mSkills.setUp(); + mMagicEffects.setUp(); + mAttributes.setUp(); +} + } // end namespace diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 226b758dc6..525341a309 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -1,145 +1,362 @@ -#ifndef OPENMW_MWWORLD_STORE_H -#define OPENMW_MWWORLD_STORE_H +#ifndef OPENMW_MWWORLD_ESMSTORE_H +#define OPENMW_MWWORLD_ESMSTORE_H -/* - The ESM storage module. - - This is separate from the ESM loader module, located in esm/. It is - also unaware of the cell loading and storage module. - - The advantage of this, as with all other modularizations, is that - you can replace the storage method later without touching the - loading code. Cutting down dependencies also help on the general - maintainability. - */ +#include <stdexcept> #include <components/esm/records.hpp> -#include "reclists.hpp" +#include "store.hpp" namespace MWWorld { - - struct ESMStore - { - /* Lists all the list types. Mostly used for quick lookup on - loading. The key is the record name (4 chars) parsed as a 32 - bit int. See esm/records.hpp for the complete list. - */ - RecListList recLists; - - // Each individual list - RecListT<ESM::Activator> activators; - RecListWithIDT<ESM::Potion> potions; - RecListT<ESM::Apparatus> appas; - RecListT<ESM::Armor> armors; - RecListT<ESM::BodyPart> bodyParts; - RecListWithIDT<ESM::Book> books; - RecListT<ESM::BirthSign> birthSigns; - RecListT<ESM::Class> classes; - RecListT<ESM::Clothing> clothes; - RecListT<ESM::LoadCNTC> contChange; - RecListT<ESM::Container> containers; - RecListWithIDT<ESM::Creature> creatures; - RecListT<ESM::LoadCREC> creaChange; - RecListCaseT<ESM::Dialogue> dialogs; - RecListT<ESM::Door> doors; - RecListT<ESM::Enchantment> enchants; - RecListT<ESM::Faction> factions; - RecListT<ESM::Global> globals; - RecListWithIDT<ESM::Ingredient> ingreds; - RecListT<ESM::CreatureLevList> creatureLists; - RecListT<ESM::ItemLevList> itemLists; - RecListT<ESM::Light> lights; - RecListT<ESM::Tool> lockpicks; - RecListT<ESM::Miscellaneous> miscItems; - RecListWithIDT<ESM::NPC> npcs; - RecListT<ESM::LoadNPCC> npcChange; - RecListT<ESM::Probe> probes; - RecListT<ESM::Race> races; - RecListT<ESM::Region> regions; - RecListT<ESM::Repair> repairs; - RecListT<ESM::SoundGenerator> soundGens; - RecListT<ESM::Sound> sounds; - RecListT<ESM::Spell> spells; - RecListT<ESM::StartScript> startScripts; - RecListT<ESM::Static> statics; - RecListT<ESM::Weapon> weapons; - - // Lists that need special rules - CellList cells; - RecListWithIDT<ESM::GameSetting> gameSettings; - LandList lands; - LTexList landTexts; - ScriptListT<ESM::Script> scripts; - IndexListT<ESM::MagicEffect> magicEffects; - IndexListT<ESM::Skill> skills; - //RecListT<ESM::Pathgrid> pathgrids; - PathgridList pathgrids; - - // Special entry which is hardcoded and not loaded from an ESM - IndexListT<ESM::Attribute> attributes; - - // Lookup of all IDs. Makes looking up references faster. Just - // maps the id name to the record type. - typedef std::map<std::string, int> AllMap; - AllMap all; - - // Look up the given ID in 'all'. Returns 0 if not found. - int find(const std::string &id) const + class ESMStore { - AllMap::const_iterator it = all.find(id); - if(it == all.end()) return 0; - return it->second; + Store<ESM::Activator> mActivators; + Store<ESM::Potion> mPotions; + Store<ESM::Apparatus> mAppas; + Store<ESM::Armor> mArmors; + Store<ESM::BodyPart> mBodyParts; + Store<ESM::Book> mBooks; + Store<ESM::BirthSign> mBirthSigns; + Store<ESM::Class> mClasses; + Store<ESM::Clothing> mClothes; + Store<ESM::LoadCNTC> mContChange; + Store<ESM::Container> mContainers; + Store<ESM::Creature> mCreatures; + Store<ESM::LoadCREC> mCreaChange; + Store<ESM::Dialogue> mDialogs; + Store<ESM::Door> mDoors; + Store<ESM::Enchantment> mEnchants; + Store<ESM::Faction> mFactions; + Store<ESM::Global> mGlobals; + Store<ESM::Ingredient> mIngreds; + Store<ESM::CreatureLevList> mCreatureLists; + Store<ESM::ItemLevList> mItemLists; + Store<ESM::Light> mLights; + Store<ESM::Tool> mLockpicks; + Store<ESM::Miscellaneous> mMiscItems; + Store<ESM::NPC> mNpcs; + Store<ESM::LoadNPCC> mNpcChange; + Store<ESM::Probe> mProbes; + Store<ESM::Race> mRaces; + Store<ESM::Region> mRegions; + Store<ESM::Repair> mRepairs; + Store<ESM::SoundGenerator> mSoundGens; + Store<ESM::Sound> mSounds; + Store<ESM::Spell> mSpells; + Store<ESM::StartScript> mStartScripts; + Store<ESM::Static> mStatics; + Store<ESM::Weapon> mWeapons; + + Store<ESM::GameSetting> mGameSettings; + Store<ESM::Script> mScripts; + + // Lists that need special rules + Store<ESM::Cell> mCells; + Store<ESM::Land> mLands; + Store<ESM::LandTexture> mLandTextures; + Store<ESM::Pathgrid> mPathgrids; + + Store<ESM::MagicEffect> mMagicEffects; + Store<ESM::Skill> mSkills; + + // Special entry which is hardcoded and not loaded from an ESM + Store<ESM::Attribute> mAttributes; + + // Lookup of all IDs. Makes looking up references faster. Just + // maps the id name to the record type. + std::map<std::string, int> mIds; + std::map<int, StoreBase *> mStores; + + public: + // Look up the given ID in 'all'. Returns 0 if not found. + int find(const std::string &id) const + { + std::map<std::string, int>::const_iterator it = mIds.find(id); + if (it == mIds.end()) { + return 0; + } + return it->second; + } + + ESMStore() + { + mStores[ESM::REC_ACTI] = &mActivators; + mStores[ESM::REC_ALCH] = &mPotions; + mStores[ESM::REC_APPA] = &mAppas; + mStores[ESM::REC_ARMO] = &mArmors; + mStores[ESM::REC_BODY] = &mBodyParts; + mStores[ESM::REC_BOOK] = &mBooks; + mStores[ESM::REC_BSGN] = &mBirthSigns; + mStores[ESM::REC_CELL] = &mCells; + mStores[ESM::REC_CLAS] = &mClasses; + mStores[ESM::REC_CLOT] = &mClothes; + mStores[ESM::REC_CNTC] = &mContChange; + mStores[ESM::REC_CONT] = &mContainers; + mStores[ESM::REC_CREA] = &mCreatures; + mStores[ESM::REC_CREC] = &mCreaChange; + mStores[ESM::REC_DIAL] = &mDialogs; + mStores[ESM::REC_DOOR] = &mDoors; + mStores[ESM::REC_ENCH] = &mEnchants; + mStores[ESM::REC_FACT] = &mFactions; + mStores[ESM::REC_GLOB] = &mGlobals; + mStores[ESM::REC_GMST] = &mGameSettings; + mStores[ESM::REC_INGR] = &mIngreds; + mStores[ESM::REC_LAND] = &mLands; + mStores[ESM::REC_LEVC] = &mCreatureLists; + mStores[ESM::REC_LEVI] = &mItemLists; + mStores[ESM::REC_LIGH] = &mLights; + mStores[ESM::REC_LOCK] = &mLockpicks; + mStores[ESM::REC_LTEX] = &mLandTextures; + mStores[ESM::REC_MISC] = &mMiscItems; + mStores[ESM::REC_NPC_] = &mNpcs; + mStores[ESM::REC_NPCC] = &mNpcChange; + mStores[ESM::REC_PGRD] = &mPathgrids; + mStores[ESM::REC_PROB] = &mProbes; + mStores[ESM::REC_RACE] = &mRaces; + mStores[ESM::REC_REGN] = &mRegions; + mStores[ESM::REC_REPA] = &mRepairs; + mStores[ESM::REC_SCPT] = &mScripts; + mStores[ESM::REC_SNDG] = &mSoundGens; + mStores[ESM::REC_SOUN] = &mSounds; + mStores[ESM::REC_SPEL] = &mSpells; + mStores[ESM::REC_SSCR] = &mStartScripts; + mStores[ESM::REC_STAT] = &mStatics; + mStores[ESM::REC_WEAP] = &mWeapons; + } + + void load(ESM::ESMReader &esm); + void setUp(); + + template <class T> + const Store<T> &get() const { + throw std::runtime_error("Storage for this type not exist"); + } + }; + + template <> + const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { + return mActivators; } - ESMStore() - { - recLists[ESM::REC_ACTI] = &activators; - recLists[ESM::REC_ALCH] = &potions; - recLists[ESM::REC_APPA] = &appas; - recLists[ESM::REC_ARMO] = &armors; - recLists[ESM::REC_BODY] = &bodyParts; - recLists[ESM::REC_BOOK] = &books; - recLists[ESM::REC_BSGN] = &birthSigns; - recLists[ESM::REC_CELL] = &cells; - recLists[ESM::REC_CLAS] = &classes; - recLists[ESM::REC_CLOT] = &clothes; - recLists[ESM::REC_CNTC] = &contChange; - recLists[ESM::REC_CONT] = &containers; - recLists[ESM::REC_CREA] = &creatures; - recLists[ESM::REC_CREC] = &creaChange; - recLists[ESM::REC_DIAL] = &dialogs; - recLists[ESM::REC_DOOR] = &doors; - recLists[ESM::REC_ENCH] = &enchants; - recLists[ESM::REC_FACT] = &factions; - recLists[ESM::REC_GLOB] = &globals; - recLists[ESM::REC_GMST] = &gameSettings; - recLists[ESM::REC_INGR] = &ingreds; - recLists[ESM::REC_LAND] = &lands; - recLists[ESM::REC_LEVC] = &creatureLists; - recLists[ESM::REC_LEVI] = &itemLists; - recLists[ESM::REC_LIGH] = &lights; - recLists[ESM::REC_LOCK] = &lockpicks; - recLists[ESM::REC_LTEX] = &landTexts; - recLists[ESM::REC_MISC] = &miscItems; - recLists[ESM::REC_NPC_] = &npcs; - recLists[ESM::REC_NPCC] = &npcChange; - recLists[ESM::REC_PGRD] = &pathgrids; - recLists[ESM::REC_PROB] = &probes; - recLists[ESM::REC_RACE] = &races; - recLists[ESM::REC_REGN] = ®ions; - recLists[ESM::REC_REPA] = &repairs; - recLists[ESM::REC_SCPT] = &scripts; - recLists[ESM::REC_SNDG] = &soundGens; - recLists[ESM::REC_SOUN] = &sounds; - recLists[ESM::REC_SPEL] = &spells; - recLists[ESM::REC_SSCR] = &startScripts; - recLists[ESM::REC_STAT] = &statics; - recLists[ESM::REC_WEAP] = &weapons; + template <> + const Store<ESM::Potion> &ESMStore::get<ESM::Potion>() const { + return mPotions; } - void load(ESM::ESMReader &esm); - }; + template <> + const Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() const { + return mAppas; + } + + template <> + const Store<ESM::Armor> &ESMStore::get<ESM::Armor>() const { + return mArmors; + } + + template <> + const Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() const { + return mBodyParts; + } + + template <> + const Store<ESM::Book> &ESMStore::get<ESM::Book>() const { + return mBooks; + } + + template <> + const Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() const { + return mBirthSigns; + } + + template <> + const Store<ESM::Class> &ESMStore::get<ESM::Class>() const { + return mClasses; + } + + template <> + const Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() const { + return mClothes; + } + + template <> + const Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() const { + return mContChange; + } + + template <> + const Store<ESM::Container> &ESMStore::get<ESM::Container>() const { + return mContainers; + } + + template <> + const Store<ESM::Creature> &ESMStore::get<ESM::Creature>() const { + return mCreatures; + } + + template <> + const Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() const { + return mCreaChange; + } + + template <> + const Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() const { + return mDialogs; + } + + template <> + const Store<ESM::Door> &ESMStore::get<ESM::Door>() const { + return mDoors; + } + + template <> + const Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() const { + return mEnchants; + } + + template <> + const Store<ESM::Faction> &ESMStore::get<ESM::Faction>() const { + return mFactions; + } + + template <> + const Store<ESM::Global> &ESMStore::get<ESM::Global>() const { + return mGlobals; + } + + template <> + const Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() const { + return mIngreds; + } + + template <> + const Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() const { + return mCreatureLists; + } + + template <> + const Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() const { + return mItemLists; + } + + template <> + const Store<ESM::Light> &ESMStore::get<ESM::Light>() const { + return mLights; + } + + template <> + const Store<ESM::Tool> &ESMStore::get<ESM::Tool>() const { + return mLockpicks; + } + + template <> + const Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() const { + return mMiscItems; + } + + template <> + const Store<ESM::NPC> &ESMStore::get<ESM::NPC>() const { + return mNpcs; + } + + template <> + const Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() const { + return mNpcChange; + } + + template <> + const Store<ESM::Probe> &ESMStore::get<ESM::Probe>() const { + return mProbes; + } + + template <> + const Store<ESM::Race> &ESMStore::get<ESM::Race>() const { + return mRaces; + } + + template <> + const Store<ESM::Region> &ESMStore::get<ESM::Region>() const { + return mRegions; + } + + template <> + const Store<ESM::Repair> &ESMStore::get<ESM::Repair>() const { + return mRepairs; + } + + template <> + const Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() const { + return mSoundGens; + } + + template <> + const Store<ESM::Sound> &ESMStore::get<ESM::Sound>() const { + return mSounds; + } + + template <> + const Store<ESM::Spell> &ESMStore::get<ESM::Spell>() const { + return mSpells; + } + + template <> + const Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() const { + return mStartScripts; + } + + template <> + const Store<ESM::Static> &ESMStore::get<ESM::Static>() const { + return mStatics; + } + + template <> + const Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() const { + return mWeapons; + } + + template <> + const Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() const { + return mGameSettings; + } + + template <> + const Store<ESM::Script> &ESMStore::get<ESM::Script>() const { + return mScripts; + } + + template <> + const Store<ESM::Cell> &ESMStore::get<ESM::Cell>() const { + return mCells; + } + + template <> + const Store<ESM::Land> &ESMStore::get<ESM::Land>() const { + return mLands; + } + + template <> + const Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() const { + return mLandTextures; + } + + template <> + const Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() const { + return mPathgrids; + } + + template <> + const Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() const { + return mMagicEffects; + } + + template <> + const Store<ESM::Skill> &ESMStore::get<ESM::Skill>() const { + return mSkills; + } + + template <> + const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { + return mAttributes; + } } #endif diff --git a/apps/openmw/mwworld/reclists.hpp b/apps/openmw/mwworld/reclists.hpp deleted file mode 100644 index 179a7ac7c1..0000000000 --- a/apps/openmw/mwworld/reclists.hpp +++ /dev/null @@ -1,620 +0,0 @@ -#ifndef OPENMW_MWWORLD_RECLISTS_H -#define OPENMW_MWWORLD_RECLISTS_H - -#include <components/esm/records.hpp> -#include <map> -#include <string> -#include <vector> -#include <algorithm> -#include <cctype> -#include <cassert> -#include <stdexcept> -#include <iterator> -#include <boost/algorithm/string.hpp> - -using namespace boost::algorithm; - -namespace MWWorld -{ - struct RecList - { - virtual ~RecList() {} - - virtual void load(ESM::ESMReader &esm, const std::string &id) = 0; - virtual int getSize() = 0; - virtual void listIdentifier (std::vector<std::string>& identifier) const = 0; - - static std::string toLower (const std::string& name) - { - std::string lowerCase; - - std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), - (int(*)(int)) std::tolower); - - return lowerCase; - } - }; - - typedef std::map<int,RecList*> RecListList; - - template <typename X> - struct RecListT : RecList - { - virtual ~RecListT() {} - - typedef std::map<std::string,X> MapType; - - MapType list; - - // Load one object of this type - void load(ESM::ESMReader &esm, const std::string &id) - { - std::string id2 = toLower (id); - list[id2].load(esm); - } - - // Find the given object ID, or return NULL if not found. - const X* search(const std::string &id) const - { - std::string id2 = toLower (id); - - typename MapType::const_iterator iter = list.find (id2); - - if (iter == list.end()) - return NULL; - - return &iter->second; - } - - // Find the given object ID (throws an exception if not found) - const X* find(const std::string &id) const - { - const X *object = search (id); - - if (!object) - throw std::runtime_error ("object " + id + " not found"); - - return object; - } - - int getSize() { return list.size(); } - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) - identifier.push_back (iter->first); - } - }; - - // Same as RecListT, but does not case-smash the IDs - // Note that lookups (search or find) are still case insensitive - template <typename X> - struct RecListCaseT : RecList - { - virtual ~RecListCaseT() {} - - typedef std::map<std::string,X> MapType; - - MapType list; - - // Load one object of this type - void load(ESM::ESMReader &esm, const std::string &id) - { - //std::string id2 = toLower (id); - - list[id].load(esm); - } - - // Find the given object ID, or return NULL if not found. - const X* search(const std::string &id) const - { - std::string id2 = toLower (id); - - for (typename MapType::const_iterator iter = list.begin(); - iter != list.end(); ++iter) - { - if (toLower(iter->first) == id2) - return &iter->second; - } - - return NULL; - } - - // non-const version - X* search(const std::string &id) - { - std::string id2 = toLower (id); - - for (typename MapType::iterator iter = list.begin(); - iter != list.end(); ++iter) - { - if (toLower(iter->first) == id2) - return &iter->second; - } - - return NULL; - } - - // Find the given object ID (throws an exception if not found) - const X* find(const std::string &id) const - { - const X *object = search (id); - - if (!object) - throw std::runtime_error ("object " + id + " not found"); - - return object; - } - - int getSize() { return list.size(); } - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) - identifier.push_back (iter->first); - } - }; - - /// Modified version of RecListT for records, that need to store their own ID - template <typename X> - struct RecListWithIDT : RecList - { - virtual ~RecListWithIDT() {} - - typedef std::map<std::string,X> MapType; - - MapType list; - - // Load one object of this type - void load(ESM::ESMReader &esm, const std::string &id) - { - std::string id2 = toLower (id); - list[id2].mId = id2; - list[id2].load(esm); - } - - // Find the given object ID, or return NULL if not found. - const X* search(const std::string &id) const - { - std::string id2 = toLower (id); - - typename MapType::const_iterator iter = list.find (id2); - - if (iter == list.end()) - return NULL; - return &iter->second; - } - - // Find the given object ID (throws an exception if not found) - const X* find(const std::string &id) const - { - const X *object = search (id); - - if (!object) - throw std::runtime_error ("object " + id + " not found"); - - return object; - } - - int getSize() { return list.size(); } - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) - identifier.push_back (iter->first); - } - }; - - /* Land textures are indexed by an integer number - */ - struct LTexList : RecList - { - virtual ~LTexList() {} - - // TODO: For multiple ESM/ESP files we need one list per file. - std::vector<ESM::LandTexture> ltex; - - LTexList() - { - // More than enough to hold Morrowind.esm. - ltex.reserve(128); - } - - const ESM::LandTexture* search(size_t index) const - { - assert(index < ltex.size()); - return <ex.at(index); - } - - int getSize() { return ltex.size(); } - int getSize() const { return ltex.size(); } - - virtual void listIdentifier (std::vector<std::string>& identifier) const {} - - void load(ESM::ESMReader &esm, const std::string &id) - { - ESM::LandTexture lt; - lt.load(esm); - lt.mId = id; - - // Make sure we have room for the structure - if(lt.mIndex + 1 > (int)ltex.size()) - ltex.resize(lt.mIndex+1); - - // Store it - ltex[lt.mIndex] = lt; - } - }; - - /* Landscapes are indexed by the X,Y coordinates of the exterior - cell they belong to. - */ - struct LandList : RecList - { - virtual ~LandList() - { - for ( LandMap::iterator itr = lands.begin(); itr != lands.end(); ++itr ) - { - delete itr->second; - } - } - - // Map containing all landscapes - typedef std::pair<int, int> LandCoord; - typedef std::map<LandCoord, ESM::Land*> LandMap; - LandMap lands; - - int count; - LandList() : count(0) {} - int getSize() { return count; } - - virtual void listIdentifier (std::vector<std::string>& identifier) const {} - - // Find land for the given coordinates. Return null if no mData. - ESM::Land *search(int x, int y) const - { - LandMap::const_iterator itr = lands.find(std::make_pair (x, y)); - if ( itr == lands.end() ) - { - return NULL; - } - - return itr->second; - } - - void load(ESM::ESMReader &esm, const std::string &id) - { - count++; - - // Create the structure and load it. This actually skips the - // landscape data and remembers the file position for later. - ESM::Land *land = new ESM::Land(); - land->load(esm); - - // Store the structure - lands[std::make_pair (land->mX, land->mY)] = land; - } - }; - - struct ciLessBoost : std::binary_function<std::string, std::string, bool> -{ - bool operator() (const std::string & s1, const std::string & s2) const { - //case insensitive version of is_less - return lexicographical_compare(s1, s2, is_iless()); - } -}; - - - // Cells aren't simply indexed by name. Exterior cells are treated - // separately. - // TODO: case handling (cell names are case-insensitive, but they are also showen to the - // player, so we can't simply smash case. - struct CellList : RecList - { - // Total cell count. Used for statistics. - int count; - CellList() : count(0) {} - int getSize() { return count; } - - // List of interior cells. Indexed by cell name. - typedef std::map<std::string,ESM::Cell*, ciLessBoost> IntCells; - IntCells intCells; - - // List of exterior cells. Indexed as extCells[mX][mY]. - typedef std::map<std::pair<int, int>, ESM::Cell*> ExtCells; - ExtCells extCells; - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - for (IntCells::const_iterator iter (intCells.begin()); iter!=intCells.end(); ++iter) - identifier.push_back (iter->first); - } - - virtual ~CellList() - { - for (IntCells::iterator it = intCells.begin(); it!=intCells.end(); ++it) - delete it->second; - - for (ExtCells::iterator it = extCells.begin(); it!=extCells.end(); ++it) - delete it->second; - } - - const ESM::Cell* searchInt(const std::string &id) const - { - IntCells::const_iterator iter = intCells.find(id); - - if (iter!=intCells.end()) - return iter->second; - - return 0; - } - - const ESM::Cell* findInt(const std::string &id) const - { - const ESM::Cell *cell = searchInt (id); - - if (!cell) - throw std::runtime_error ("Interior cell not found - " + id); - - return cell; - } - - const ESM::Cell *searchExt (int x, int y) const - { - ExtCells::const_iterator it = extCells.find (std::make_pair (x, y)); - - if (it==extCells.end()) - return 0; - - return it->second; - } - - const ESM::Cell *findExt (int x, int y) const - { - const ESM::Cell *cell = searchExt (x, y); - - if (!cell) - throw std::runtime_error ("Exterior cell not found"); - - return cell; - } - const ESM::Cell *searchExtByName (const std::string& id) const - { - for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) - { - if (toLower (iter->second->mName) == toLower (id)) - return iter->second; - } - - return 0; - } - - const ESM::Cell *searchExtByRegion (const std::string& id) const - { - std::string id2 = toLower (id); - - for (ExtCells::const_iterator iter = extCells.begin(); iter!=extCells.end(); ++iter) - if (toLower (iter->second->mRegion)==id) - return iter->second; - - return 0; - } - - void load(ESM::ESMReader &esm, const std::string &id) - { - count++; - - // All cells have a name record, even nameless exterior cells. - ESM::Cell *cell = new ESM::Cell; - cell->mName = id; - - // The cell itself takes care of all the hairy details - cell->load(esm); - - if(cell->mData.mFlags & ESM::Cell::Interior) - { - // Store interior cell by name - intCells[id] = cell; - } - else - { - // Store exterior cells by grid position - extCells[std::make_pair (cell->mData.mX, cell->mData.mY)] = cell; - } - } - }; - - struct PathgridList : RecList - { - int count; - - // List of grids for interior cells. Indexed by cell name. - typedef std::map<std::string,ESM::Pathgrid*, ciLessBoost> IntGrids; - IntGrids intGrids; - - // List of grids for exterior cells. Indexed as extCells[mX][mY]. - typedef std::map<std::pair<int, int>, ESM::Pathgrid*> ExtGrids; - ExtGrids extGrids; - - PathgridList() : count(0) {} - - virtual ~PathgridList() - { - for (IntGrids::iterator it = intGrids.begin(); it!=intGrids.end(); ++it) - delete it->second; - - for (ExtGrids::iterator it = extGrids.begin(); it!=extGrids.end(); ++it) - delete it->second; - } - - int getSize() { return count; } - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - // do nothing - } - - void load(ESM::ESMReader &esm, const std::string &id) - { - count++; - ESM::Pathgrid *grid = new ESM::Pathgrid; - grid->load(esm); - if (grid->mData.mX == 0 && grid->mData.mY == 0) - { - intGrids[grid->mCell] = grid; - } - else - { - extGrids[std::make_pair(grid->mData.mX, grid->mData.mY)] = grid; - } - } - - ESM::Pathgrid *find(int cellX, int cellY, const std::string &cellName) const - { - ESM::Pathgrid *result = search(cellX, cellY, cellName); - if (!result) - { - throw std::runtime_error("no pathgrid found for cell " + cellName); - } - return result; - } - - ESM::Pathgrid *search(int cellX, int cellY, const std::string &cellName) const - { - ESM::Pathgrid *result = NULL; - if (cellX == 0 && cellY == 0) // possibly interior - { - IntGrids::const_iterator it = intGrids.find(cellName); - if (it != intGrids.end()) - result = it->second; - } - else - { - ExtGrids::const_iterator it = extGrids.find(std::make_pair(cellX, cellY)); - if (it != extGrids.end()) - result = it->second; - } - return result; - } - - ESM::Pathgrid *search(const ESM::Cell &cell) const - { - int cellX, cellY; - if (cell.mData.mFlags & ESM::Cell::Interior) - { - cellX = cellY = 0; - } - else - { - cellX = cell.mData.mX; - cellY = cell.mData.mY; - } - return search(cellX, cellY, cell.mName); - } - }; - - template <typename X> - struct ScriptListT : RecList - { - virtual ~ScriptListT() {} - - typedef std::map<std::string,X> MapType; - - MapType list; - - // Load one object of this type - void load(ESM::ESMReader &esm, const std::string &id) - { - X ref; - ref.load (esm); - - std::string realId = toLower (ref.mId); - - std::swap (list[realId], ref); - } - - // Find the given object ID, or return NULL if not found. - const X* search(const std::string &id) const - { - std::string id2 = toLower (id); - - typename MapType::const_iterator iter = list.find (id2); - - if (iter == list.end()) - return NULL; - - return &iter->second; - } - - // Find the given object ID (throws an exception if not found) - const X* find(const std::string &id) const - { - const X *object = search (id); - - if (!object) - throw std::runtime_error ("object " + id + " not found"); - - return object; - } - - int getSize() { return list.size(); } - - virtual void listIdentifier (std::vector<std::string>& identifier) const - { - for (typename MapType::const_iterator iter (list.begin()); iter!=list.end(); ++iter) - identifier.push_back (iter->first); - } - }; - - template <typename X> - struct IndexListT - { - virtual ~IndexListT() {} - - typedef std::map<int, X> MapType; - - MapType list; - - void load(ESM::ESMReader &esm) - { - X ref; - ref.load (esm); - int index = ref.mIndex; - list[index] = ref; - } - - int getSize() - { - return list.size(); - } - - virtual void listIdentifier (std::vector<std::string>& identifier) const {} - - // Find the given object ID, or return NULL if not found. - const X* search (int id) const - { - typename MapType::const_iterator iter = list.find (id); - - if (iter == list.end()) - return NULL; - - return &iter->second; - } - - // Find the given object ID (throws an exception if not found) - const X* find (int id) const - { - const X *object = search (id); - - if (!object) - { - std::ostringstream error; - error << "object " << id << " not found"; - throw std::runtime_error (error.str()); - } - - return object; - } - }; -} -#endif diff --git a/apps/openmw/mwworld/storedevel/recordcmp.hpp b/apps/openmw/mwworld/recordcmp.hpp similarity index 100% rename from apps/openmw/mwworld/storedevel/recordcmp.hpp rename to apps/openmw/mwworld/recordcmp.hpp diff --git a/apps/openmw/mwworld/storedevel/store.hpp b/apps/openmw/mwworld/store.hpp similarity index 100% rename from apps/openmw/mwworld/storedevel/store.hpp rename to apps/openmw/mwworld/store.hpp diff --git a/apps/openmw/mwworld/storedevel/esmstore.cpp b/apps/openmw/mwworld/storedevel/esmstore.cpp deleted file mode 100644 index eb236d1bc2..0000000000 --- a/apps/openmw/mwworld/storedevel/esmstore.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "esmstore.hpp" - -#include <set> -#include <iostream> - -namespace MWWorld -{ - -static bool isCacheableRecord(int id) -{ - if (id == ESM::REC_ACTI || id == ESM::REC_ALCH || id == ESM::REC_APPA || id == ESM::REC_ARMO || - id == ESM::REC_BOOK || id == ESM::REC_CLOT || id == ESM::REC_CONT || id == ESM::REC_CREA || - id == ESM::REC_DOOR || id == ESM::REC_INGR || id == ESM::REC_LEVC || id == ESM::REC_LEVI || - id == ESM::REC_LIGH || id == ESM::REC_LOCK || id == ESM::REC_MISC || id == ESM::REC_NPC_ || - id == ESM::REC_PROB || id == ESM::REC_REPA || id == ESM::REC_STAT || id == ESM::REC_WEAP) - { - return true; - } - return false; -} - -void ESMStore::load(ESM::ESMReader &esm) -{ - std::set<std::string> missing; - - ESM::Dialogue *dialogue = 0; - - // Loop through all records - while(esm.hasMoreRecs()) - { - ESM::NAME n = esm.getRecName(); - esm.getRecHeader(); - - // Look up the record type. - std::map<int, StoreBase *>::iterator it = mStores.find(n.val); - - if (it == mStores.end()) { - if (n.val == ESM::REC_INFO) { - if (dialogue) { - dialogue->mInfo.push_back(ESM::DialInfo()); - dialogue->mInfo.back().load(esm); - } else { - std::cerr << "error: info record without dialog" << std::endl; - esm.skipRecord(); - } - } else if (n.val == ESM::REC_MGEF) { - mMagicEffects.load (esm); - } else if (n.val == ESM::REC_SKIL) { - mSkills.load (esm); - } else { - // Not found (this would be an error later) - esm.skipRecord(); - missing.insert(n.toString()); - } - } else { - // Load it - std::string id = esm.getHNOString("NAME"); - it->second->load(esm, id); - - if (n.val==ESM::REC_DIAL) { - // dirty hack, but it is better than non-const search() - // or friends - dialogue = const_cast<ESM::Dialogue *>(mDialogs.search(id)); - assert (dialogue != NULL); - } else { - dialogue = 0; - } - // Insert the reference into the global lookup - if (!id.empty() && isCacheableRecord(n.val)) { - mIds[id] = n.val; - } - } - } - - /* This information isn't needed on screen. But keep the code around - for debugging purposes later. - - cout << "\n" << mStores.size() << " record types:\n"; - for(RecListList::iterator it = mStores.begin(); it != mStores.end(); it++) - cout << " " << toStr(it->first) << ": " << it->second->getSize() << endl; - cout << "\nNot implemented yet: "; - for(set<string>::iterator it = missing.begin(); - it != missing.end(); it++ ) - cout << *it << " "; - cout << endl; - */ -} - -void ESMStore::setUp() -{ - std::map<int, StoreBase *>::iterator it = mStores.begin(); - for (; it != mStores.end(); ++it) { - it->second->setUp(); - } - mSkills.setUp(); - mMagicEffects.setUp(); - mAttributes.setUp(); -} - -} // end namespace diff --git a/apps/openmw/mwworld/storedevel/esmstore.hpp b/apps/openmw/mwworld/storedevel/esmstore.hpp deleted file mode 100644 index 525341a309..0000000000 --- a/apps/openmw/mwworld/storedevel/esmstore.hpp +++ /dev/null @@ -1,362 +0,0 @@ -#ifndef OPENMW_MWWORLD_ESMSTORE_H -#define OPENMW_MWWORLD_ESMSTORE_H - -#include <stdexcept> - -#include <components/esm/records.hpp> -#include "store.hpp" - -namespace MWWorld -{ - class ESMStore - { - Store<ESM::Activator> mActivators; - Store<ESM::Potion> mPotions; - Store<ESM::Apparatus> mAppas; - Store<ESM::Armor> mArmors; - Store<ESM::BodyPart> mBodyParts; - Store<ESM::Book> mBooks; - Store<ESM::BirthSign> mBirthSigns; - Store<ESM::Class> mClasses; - Store<ESM::Clothing> mClothes; - Store<ESM::LoadCNTC> mContChange; - Store<ESM::Container> mContainers; - Store<ESM::Creature> mCreatures; - Store<ESM::LoadCREC> mCreaChange; - Store<ESM::Dialogue> mDialogs; - Store<ESM::Door> mDoors; - Store<ESM::Enchantment> mEnchants; - Store<ESM::Faction> mFactions; - Store<ESM::Global> mGlobals; - Store<ESM::Ingredient> mIngreds; - Store<ESM::CreatureLevList> mCreatureLists; - Store<ESM::ItemLevList> mItemLists; - Store<ESM::Light> mLights; - Store<ESM::Tool> mLockpicks; - Store<ESM::Miscellaneous> mMiscItems; - Store<ESM::NPC> mNpcs; - Store<ESM::LoadNPCC> mNpcChange; - Store<ESM::Probe> mProbes; - Store<ESM::Race> mRaces; - Store<ESM::Region> mRegions; - Store<ESM::Repair> mRepairs; - Store<ESM::SoundGenerator> mSoundGens; - Store<ESM::Sound> mSounds; - Store<ESM::Spell> mSpells; - Store<ESM::StartScript> mStartScripts; - Store<ESM::Static> mStatics; - Store<ESM::Weapon> mWeapons; - - Store<ESM::GameSetting> mGameSettings; - Store<ESM::Script> mScripts; - - // Lists that need special rules - Store<ESM::Cell> mCells; - Store<ESM::Land> mLands; - Store<ESM::LandTexture> mLandTextures; - Store<ESM::Pathgrid> mPathgrids; - - Store<ESM::MagicEffect> mMagicEffects; - Store<ESM::Skill> mSkills; - - // Special entry which is hardcoded and not loaded from an ESM - Store<ESM::Attribute> mAttributes; - - // Lookup of all IDs. Makes looking up references faster. Just - // maps the id name to the record type. - std::map<std::string, int> mIds; - std::map<int, StoreBase *> mStores; - - public: - // Look up the given ID in 'all'. Returns 0 if not found. - int find(const std::string &id) const - { - std::map<std::string, int>::const_iterator it = mIds.find(id); - if (it == mIds.end()) { - return 0; - } - return it->second; - } - - ESMStore() - { - mStores[ESM::REC_ACTI] = &mActivators; - mStores[ESM::REC_ALCH] = &mPotions; - mStores[ESM::REC_APPA] = &mAppas; - mStores[ESM::REC_ARMO] = &mArmors; - mStores[ESM::REC_BODY] = &mBodyParts; - mStores[ESM::REC_BOOK] = &mBooks; - mStores[ESM::REC_BSGN] = &mBirthSigns; - mStores[ESM::REC_CELL] = &mCells; - mStores[ESM::REC_CLAS] = &mClasses; - mStores[ESM::REC_CLOT] = &mClothes; - mStores[ESM::REC_CNTC] = &mContChange; - mStores[ESM::REC_CONT] = &mContainers; - mStores[ESM::REC_CREA] = &mCreatures; - mStores[ESM::REC_CREC] = &mCreaChange; - mStores[ESM::REC_DIAL] = &mDialogs; - mStores[ESM::REC_DOOR] = &mDoors; - mStores[ESM::REC_ENCH] = &mEnchants; - mStores[ESM::REC_FACT] = &mFactions; - mStores[ESM::REC_GLOB] = &mGlobals; - mStores[ESM::REC_GMST] = &mGameSettings; - mStores[ESM::REC_INGR] = &mIngreds; - mStores[ESM::REC_LAND] = &mLands; - mStores[ESM::REC_LEVC] = &mCreatureLists; - mStores[ESM::REC_LEVI] = &mItemLists; - mStores[ESM::REC_LIGH] = &mLights; - mStores[ESM::REC_LOCK] = &mLockpicks; - mStores[ESM::REC_LTEX] = &mLandTextures; - mStores[ESM::REC_MISC] = &mMiscItems; - mStores[ESM::REC_NPC_] = &mNpcs; - mStores[ESM::REC_NPCC] = &mNpcChange; - mStores[ESM::REC_PGRD] = &mPathgrids; - mStores[ESM::REC_PROB] = &mProbes; - mStores[ESM::REC_RACE] = &mRaces; - mStores[ESM::REC_REGN] = &mRegions; - mStores[ESM::REC_REPA] = &mRepairs; - mStores[ESM::REC_SCPT] = &mScripts; - mStores[ESM::REC_SNDG] = &mSoundGens; - mStores[ESM::REC_SOUN] = &mSounds; - mStores[ESM::REC_SPEL] = &mSpells; - mStores[ESM::REC_SSCR] = &mStartScripts; - mStores[ESM::REC_STAT] = &mStatics; - mStores[ESM::REC_WEAP] = &mWeapons; - } - - void load(ESM::ESMReader &esm); - void setUp(); - - template <class T> - const Store<T> &get() const { - throw std::runtime_error("Storage for this type not exist"); - } - }; - - template <> - const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { - return mActivators; - } - - template <> - const Store<ESM::Potion> &ESMStore::get<ESM::Potion>() const { - return mPotions; - } - - template <> - const Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() const { - return mAppas; - } - - template <> - const Store<ESM::Armor> &ESMStore::get<ESM::Armor>() const { - return mArmors; - } - - template <> - const Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() const { - return mBodyParts; - } - - template <> - const Store<ESM::Book> &ESMStore::get<ESM::Book>() const { - return mBooks; - } - - template <> - const Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() const { - return mBirthSigns; - } - - template <> - const Store<ESM::Class> &ESMStore::get<ESM::Class>() const { - return mClasses; - } - - template <> - const Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() const { - return mClothes; - } - - template <> - const Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() const { - return mContChange; - } - - template <> - const Store<ESM::Container> &ESMStore::get<ESM::Container>() const { - return mContainers; - } - - template <> - const Store<ESM::Creature> &ESMStore::get<ESM::Creature>() const { - return mCreatures; - } - - template <> - const Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() const { - return mCreaChange; - } - - template <> - const Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() const { - return mDialogs; - } - - template <> - const Store<ESM::Door> &ESMStore::get<ESM::Door>() const { - return mDoors; - } - - template <> - const Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() const { - return mEnchants; - } - - template <> - const Store<ESM::Faction> &ESMStore::get<ESM::Faction>() const { - return mFactions; - } - - template <> - const Store<ESM::Global> &ESMStore::get<ESM::Global>() const { - return mGlobals; - } - - template <> - const Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() const { - return mIngreds; - } - - template <> - const Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() const { - return mCreatureLists; - } - - template <> - const Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() const { - return mItemLists; - } - - template <> - const Store<ESM::Light> &ESMStore::get<ESM::Light>() const { - return mLights; - } - - template <> - const Store<ESM::Tool> &ESMStore::get<ESM::Tool>() const { - return mLockpicks; - } - - template <> - const Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() const { - return mMiscItems; - } - - template <> - const Store<ESM::NPC> &ESMStore::get<ESM::NPC>() const { - return mNpcs; - } - - template <> - const Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() const { - return mNpcChange; - } - - template <> - const Store<ESM::Probe> &ESMStore::get<ESM::Probe>() const { - return mProbes; - } - - template <> - const Store<ESM::Race> &ESMStore::get<ESM::Race>() const { - return mRaces; - } - - template <> - const Store<ESM::Region> &ESMStore::get<ESM::Region>() const { - return mRegions; - } - - template <> - const Store<ESM::Repair> &ESMStore::get<ESM::Repair>() const { - return mRepairs; - } - - template <> - const Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() const { - return mSoundGens; - } - - template <> - const Store<ESM::Sound> &ESMStore::get<ESM::Sound>() const { - return mSounds; - } - - template <> - const Store<ESM::Spell> &ESMStore::get<ESM::Spell>() const { - return mSpells; - } - - template <> - const Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() const { - return mStartScripts; - } - - template <> - const Store<ESM::Static> &ESMStore::get<ESM::Static>() const { - return mStatics; - } - - template <> - const Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() const { - return mWeapons; - } - - template <> - const Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() const { - return mGameSettings; - } - - template <> - const Store<ESM::Script> &ESMStore::get<ESM::Script>() const { - return mScripts; - } - - template <> - const Store<ESM::Cell> &ESMStore::get<ESM::Cell>() const { - return mCells; - } - - template <> - const Store<ESM::Land> &ESMStore::get<ESM::Land>() const { - return mLands; - } - - template <> - const Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() const { - return mLandTextures; - } - - template <> - const Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() const { - return mPathgrids; - } - - template <> - const Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() const { - return mMagicEffects; - } - - template <> - const Store<ESM::Skill> &ESMStore::get<ESM::Skill>() const { - return mSkills; - } - - template <> - const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { - return mAttributes; - } -} - -#endif From bd1bb2e55d6b764be8143717b003cd2f09fe57d8 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 18:39:42 +0400 Subject: [PATCH 125/255] applying new interface vol.1, inconsistent --- apps/openmw/mwclass/armor.cpp | 9 ++++++--- apps/openmw/mwclass/door.cpp | 5 +++-- apps/openmw/mwclass/misc.cpp | 10 +++++----- apps/openmw/mwclass/npc.cpp | 6 ++++-- apps/openmw/mwclass/weapon.cpp | 4 ++-- apps/openmw/mwmechanics/alchemy.cpp | 26 ++++++++++++++------------ 6 files changed, 34 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 36a1b25c49..3b82f9c48c 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -152,13 +152,16 @@ namespace MWClass if (typeGmst.empty()) return -1; - float iWeight = MWBase::Environment::get().getWorld()->getStore().gameSettings.find (typeGmst)->getInt(); + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); - if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fLightMaxMod")->getFloat()>= + float iWeight = gmst.find (typeGmst)->getInt(); + + if (iWeight * gmst.find ("fLightMaxMod")->getFloat()>= ref->mBase->mData.mWeight) return ESM::Skill::LightArmor; - if (iWeight * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMedMaxMod")->getFloat()>= + if (iWeight * gmst.get<ESM::GameSetting>().find ("fMedMaxMod")->getFloat()>= ref->mBase->mData.mWeight) return ESM::Skill::MediumArmor; diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index cb87398979..14012db10b 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -220,12 +220,13 @@ namespace MWClass // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; MWBase::Environment::get().getWorld()->positionToIndex (ref->mRef.mDoorDest.pos[0], ref->mRef.mDoorDest.pos[1], x, y); - const ESM::Cell* cell = store.cells.findExt(x,y); + const ESM::Cell* cell = store.get<ESM::Cell>().find(x,y); if (cell->mName != "") dest = cell->mName; else { - const ESM::Region* region = store.regions.search(cell->mRegion); + const ESM::Region* region = + store.get<ESM::Region>().find(cell->mRegion); dest = region->mName; } } diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index ba66c5cfcf..9aa02530fc 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -101,7 +101,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString()) { return std::string("Item Gold Up"); } @@ -113,7 +113,7 @@ namespace MWClass MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = ptr.get<ESM::Miscellaneous>(); - if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (ref->mBase->mName == MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGold")->getString()) { return std::string("Item Gold Down"); } @@ -147,7 +147,7 @@ namespace MWClass int count = ptr.getRefData().getCount(); - bool isGold = (ref->mBase->mName == store.gameSettings.find("sGold")->getString()); + bool isGold = (ref->mBase->mName == store.get<ESM::GameSetting>().find("sGold")->getString()); if (isGold && count == 1) count = ref->mBase->mData.mValue; @@ -162,7 +162,7 @@ namespace MWClass if (ref->mRef.mSoul != "") { - const ESM::Creature *creature = store.creatures.search(ref->mRef.mSoul); + const ESM::Creature *creature = store.get<ESM::Creature>().find(ref->mRef.mSoul); info.caption += " (" + creature->mName + ")"; } @@ -192,7 +192,7 @@ namespace MWClass const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - if (MWWorld::Class::get(ptr).getName(ptr) == store.gameSettings.find("sGold")->getString()) { + if (MWWorld::Class::get(ptr).getName(ptr) == store.get<ESM::GameSetting().find("sGold")->getString()) { int goldAmount = ptr.getRefData().getCount(); std::string base = "Gold_001"; diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 9da02895b4..9d8ee61894 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -395,8 +395,10 @@ namespace MWClass MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); - const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - ref->mBase->mClass); + const ESM::Class *class_ = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find ( + ref->mBase->mClass + ); stats.useSkill (skill, *class_, usageType); } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 0312ed6282..0d5dcab11e 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -303,8 +303,8 @@ namespace MWClass std::string type = mapping[ref->mBase->mData.mType].first; std::string oneOrTwoHanded = mapping[ref->mBase->mData.mType].second; - text += store.gameSettings.find(type)->getString() + - ((oneOrTwoHanded != "") ? ", " + store.gameSettings.find(oneOrTwoHanded)->getString() : ""); + text += store.get<ESM::GameSetting>().find(type)->getString() + + ((oneOrTwoHanded != "") ? ", " + store.get<ESM::GameSetting>().find(oneOrTwoHanded)->getString() : ""); // weapon damage if (ref->mBase->mData.mType >= 9) diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 23478e47d1..5ccdc5750b 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -131,29 +131,29 @@ void MWMechanics::Alchemy::updateEffects() float x = getChance(); x *= mTools[ESM::Apparatus::MortarPestle].get<ESM::Apparatus>()->mBase->mData.mQuality; - x *= MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionStrengthMult")->getFloat(); + x *= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionStrengthMult")->getFloat(); // value mValue = static_cast<int> ( - x * MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("iAlchemyMod")->getFloat()); + x * MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("iAlchemyMod")->getFloat()); // build quantified effect list for (std::set<EffectKey>::const_iterator iter (effects.begin()); iter!=effects.end(); ++iter) { const ESM::MagicEffect *magicEffect = - MWBase::Environment::get().getWorld()->getStore().magicEffects.find (iter->mId); + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find (iter->mId); if (magicEffect->mData.mBaseCost<=0) throw std::runtime_error ("invalid base cost for magic effect " + iter->mId); float fPotionT1MagMul = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1MagMult")->getFloat(); + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionT1MagMult")->getFloat(); if (fPotionT1MagMul<=0) throw std::runtime_error ("invalid gmst: fPotionT1MagMul"); float fPotionT1DurMult = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fPotionT1DurMult")->getFloat(); + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find ("fPotionT1DurMult")->getFloat(); if (fPotionT1DurMult<=0) throw std::runtime_error ("invalid gmst: fPotionT1DurMult"); @@ -192,18 +192,20 @@ void MWMechanics::Alchemy::updateEffects() const ESM::Potion *MWMechanics::Alchemy::getRecord() const { - for (MWWorld::RecListWithIDT<ESM::Potion>::MapType::const_iterator iter ( - MWBase::Environment::get().getWorld()->getStore().potions.list.begin()); - iter!=MWBase::Environment::get().getWorld()->getStore().potions.list.end(); ++iter) + const MWWorld::Store<ESM::Potion> &potions = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>(); + + MWWorld::Store<ESM::Potion>::iterator iter = potions.begin(); + for (; iter != potions.end(); ++iter) { - if (iter->second.mEffects.mList.size()!=mEffects.size()) + if (iter->mEffects.mList.size() != mEffects.size()) continue; bool mismatch = false; - for (int i=0; i<static_cast<int> (iter->second.mEffects.mList.size()); ++iter) + for (int i=0; i<static_cast<int> (iter->mEffects.mList.size()); ++iter) { - const ESM::ENAMstruct& first = iter->second.mEffects.mList[i]; + const ESM::ENAMstruct& first = iter->mEffects.mList[i]; const ESM::ENAMstruct& second = mEffects[i]; if (first.mEffectID!=second.mEffectID || @@ -221,7 +223,7 @@ const ESM::Potion *MWMechanics::Alchemy::getRecord() const } if (!mismatch) - return &iter->second; + return &(*iter); } return 0; From 61942c9c4aa3ad52c5ea282464e2580a36fefa39 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Mon, 5 Nov 2012 18:01:50 +0100 Subject: [PATCH 126/255] Issue #440: Make day numbers start at 1 instead of 0 --- apps/openmw/mwgui/waitdialog.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 380fb8dd50..71fd108dcf 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -122,7 +122,7 @@ namespace MWGui if (hour >= 13) hour -= 12; std::string dateTimeText = - boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getDay ()+1) + " " + boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getDay ()) + " " + month + " (#{sDay} " + boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getTimeStamp ().getDay ()+1) + ") " + boost::lexical_cast<std::string>(hour) + " " + (pm ? "#{sSaveMenuHelp05}" : "#{sSaveMenuHelp04}"); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 7b938be5e2..2304576ec7 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -407,15 +407,15 @@ namespace MWWorld void World::setDay (int day) { - if (day<0) - day = 0; + if (day<1) + day = 1; int month = mGlobalVariables->getInt ("month"); while (true) { int days = getDaysPerMonth (month); - if (day<days) + if (day<=days) break; if (month<11) @@ -437,8 +437,6 @@ namespace MWWorld mRendering->skySetDate (day, month); mWeatherManager->setDate (day, month); - - } void World::setMonth (int month) @@ -451,8 +449,8 @@ namespace MWWorld int days = getDaysPerMonth (month); - if (mGlobalVariables->getInt ("day")>=days) - mGlobalVariables->setInt ("day", days-1); + if (mGlobalVariables->getInt ("day")>days) + mGlobalVariables->setInt ("day", days); mGlobalVariables->setInt ("month", month); From 86ad7a96f4288de26335558ceac2d210e45e1c42 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 21:19:22 +0400 Subject: [PATCH 127/255] applying new interface vol.2, inconsistent --- apps/openmw/mwmechanics/activespells.cpp | 10 ++--- apps/openmw/mwmechanics/actors.cpp | 8 ++-- apps/openmw/mwmechanics/creaturestats.cpp | 7 +-- .../mwmechanics/mechanicsmanagerimp.cpp | 44 +++++++++++-------- apps/openmw/mwmechanics/npcstats.cpp | 21 ++++----- apps/openmw/mwmechanics/spellsuccess.hpp | 9 ++-- 6 files changed, 56 insertions(+), 43 deletions(-) diff --git a/apps/openmw/mwmechanics/activespells.cpp b/apps/openmw/mwmechanics/activespells.cpp index 7deab426d4..989bdedd71 100644 --- a/apps/openmw/mwmechanics/activespells.cpp +++ b/apps/openmw/mwmechanics/activespells.cpp @@ -86,7 +86,7 @@ namespace MWMechanics if (effects.second) { const ESM::MagicEffect *magicEffect = - MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find ( iter->mEffectID); if (iter->mDuration==0) @@ -114,18 +114,18 @@ namespace MWMechanics std::pair<ESM::EffectList, bool> ActiveSpells::getEffectList (const std::string& id) const { if (const ESM::Spell *spell = - MWBase::Environment::get().getWorld()->getStore().spells.search (id)) + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().search (id)) return std::make_pair (spell->mEffects, false); if (const ESM::Potion *potion = - MWBase::Environment::get().getWorld()->getStore().potions.search (id)) + MWBase::Environment::get().getWorld()->getStore().get<ESM::Potion>().search (id)) return std::make_pair (potion->mEffects, false); if (const ESM::Ingredient *ingredient = - MWBase::Environment::get().getWorld()->getStore().ingreds.search (id)) + MWBase::Environment::get().getWorld()->getStore().get<ESM::Ingredient>().search (id)) { const ESM::MagicEffect *magicEffect = - MWBase::Environment::get().getWorld()->getStore().magicEffects.find ( + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find ( ingredient->mData.mEffectID[0]); ESM::ENAMstruct effect; diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index b5933a646f..d541baea99 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -103,9 +103,9 @@ namespace MWMechanics const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); - float fFatigueReturnBase = store.gameSettings.find("fFatigueReturnBase")->getFloat (); - float fFatigueReturnMult = store.gameSettings.find("fFatigueReturnMult")->getFloat (); - float fEndFatigueMult = store.gameSettings.find("fEndFatigueMult")->getFloat (); + float fFatigueReturnBase = store.get<ESM::GameSetting>().find("fFatigueReturnBase")->getFloat (); + float fFatigueReturnMult = store.get<ESM::GameSetting>().find("fFatigueReturnMult")->getFloat (); + float fEndFatigueMult = store.get<ESM::GameSetting>().find("fEndFatigueMult")->getFloat (); float capacity = MWWorld::Class::get(ptr).getCapacity(ptr); float encumbrance = MWWorld::Class::get(ptr).getEncumbrance(ptr); @@ -122,7 +122,7 @@ namespace MWMechanics if (!stunted) { - float fRestMagicMult = store.gameSettings.find("fRestMagicMult")->getFloat (); + float fRestMagicMult = store.get<ESM::GameSetting>().find("fRestMagicMult")->getFloat (); DynamicStat<float> magicka = stats.getMagicka(); magicka.setCurrent (magicka.getCurrent() diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 9a6a5c0f20..95e721c01b 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -41,10 +41,11 @@ namespace MWMechanics float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max); - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); - return store.gameSettings.find ("fFatigueBase")->getFloat() - - store.gameSettings.find ("fFatigueMult")->getFloat() * (1-normalised); + return gmst.find ("fFatigueBase")->getFloat() + - gmst.find ("fFatigueMult")->getFloat() * (1-normalised); } const Stat<int> &CreatureStats::getAttribute(int index) const diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index a9b6e82e8b..94418c5228 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -42,8 +42,9 @@ namespace MWMechanics if (mRaceSelected) { const ESM::Race *race = - MWBase::Environment::get().getWorld()->getStore().races.find ( - MWBase::Environment::get().getWorld()->getPlayer().getRace()); + MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find ( + MWBase::Environment::get().getWorld()->getPlayer().getRace() + ); bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); @@ -91,7 +92,7 @@ namespace MWMechanics if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty()) { const ESM::BirthSign *sign = - MWBase::Environment::get().getWorld()->getStore().birthSigns.find ( + MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find ( MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin()); @@ -132,14 +133,15 @@ namespace MWMechanics } } - typedef MWWorld::IndexListT<ESM::Skill>::MapType ContainerType; - const ContainerType& skills = MWBase::Environment::get().getWorld()->getStore().skills.list; + const MWWorld::Store<ESM::Skill> &skills = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>(); - for (ContainerType::const_iterator iter (skills.begin()); iter!=skills.end(); ++iter) + MWWorld::Store<ESM::Skill>::iterator iter = skills.begin(); + for (; iter != skills.end(); ++iter) { - if (iter->second.mData.mSpecialization==class_.mData.mSpecialization) + if (iter->mData.mSpecialization==class_.mData.mSpecialization) { - int index = iter->first; + int index = iter->mIndex; if (index>=0 && index<27) { @@ -261,12 +263,16 @@ namespace MWMechanics if (mUpdatePlayer) { // basic player profile; should not change anymore after the creation phase is finished. - MWBase::Environment::get().getWindowManager()->setValue ("name", MWBase::Environment::get().getWorld()->getPlayer().getName()); - MWBase::Environment::get().getWindowManager()->setValue ("race", - MWBase::Environment::get().getWorld()->getStore().races.find (MWBase::Environment::get().getWorld()->getPlayer(). - getRace())->mName); - MWBase::Environment::get().getWindowManager()->setValue ("class", - MWBase::Environment::get().getWorld()->getPlayer().getClass().mName); + MWBase::WindowManager *winMgr = + MWBase::Environment::get().getWindowManager(); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + MWWorld::Player &player = world->getPlayer(); + + winMgr->setValue ("name", player.getName()); + winMgr->setValue ("race", world->getStore().get<ESM::Race>().find (player.getRace())->mName); + winMgr->setValue ("class", player.getClass().mName); + mUpdatePlayer = false; MWBase::WindowManager::SkillList majorSkills (5); @@ -274,11 +280,11 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][0]; - majorSkills[i] = MWBase::Environment::get().getWorld()->getPlayer().getClass().mData.mSkills[i][1]; + minorSkills[i] = player.getClass().mData.mSkills[i][0]; + majorSkills[i] = player.getClass().mData.mSkills[i][1]; } - MWBase::Environment::get().getWindowManager()->configureSkills (majorSkills, minorSkills); + winMgr->configureSkills (majorSkills, minorSkills); } mActors.update (movement, duration, paused); @@ -313,7 +319,9 @@ namespace MWMechanics void MechanicsManager::setPlayerClass (const std::string& id) { - MWBase::Environment::get().getWorld()->getPlayer().setClass (*MWBase::Environment::get().getWorld()->getStore().classes.find (id)); + MWBase::Environment::get().getWorld()->getPlayer().setClass ( + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find (id) + ); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index e01f7cc1cb..c0da99aaf4 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -81,7 +81,8 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla if (level<0) level = static_cast<int> (getSkill (skillIndex).getBase()); - const ESM::Skill *skill = MWBase::Environment::get().getWorld()->getStore().skills.find (skillIndex); + const ESM::Skill *skill = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find (skillIndex); float skillFactor = 1; @@ -96,14 +97,15 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla throw std::runtime_error ("invalid skill gain factor"); } - float typeFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMiscSkillBonus")->getFloat(); + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + + float typeFactor = gmst.find ("fMiscSkillBonus")->getFloat(); for (int i=0; i<5; ++i) if (class_.mData.mSkills[i][0]==skillIndex) { - typeFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMinorSkillBonus")->getFloat(); + typeFactor = gmst.find ("fMinorSkillBonus")->getFloat(); break; } @@ -111,8 +113,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla for (int i=0; i<5; ++i) if (class_.mData.mSkills[i][1]==skillIndex) { - typeFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fMajorSkillBonus")->getFloat(); + typeFactor = gmst.find ("fMajorSkillBonus")->getFloat(); break; } @@ -124,8 +125,7 @@ float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& cla if (skill->mData.mSpecialization==class_.mData.mSpecialization) { - specialisationFactor = - MWBase::Environment::get().getWorld()->getStore().gameSettings.find ("fSpecialSkillBonus")->getFloat(); + specialisationFactor = gmst.find ("fSpecialSkillBonus")->getFloat(); if (specialisationFactor<=0) throw std::runtime_error ("invalid skill specialisation factor"); @@ -178,7 +178,8 @@ void MWMechanics::NpcStats::increaseSkill(int skillIndex, const ESM::Class &clas mLevelProgress += levelProgress; // check the attribute this skill belongs to - const ESM::Skill* skill = MWBase::Environment::get().getWorld ()->getStore ().skills.find(skillIndex); + const ESM::Skill* skill = + MWBase::Environment::get().getWorld ()->getStore ().get<ESM::Skill>().find(skillIndex); ++mSkillIncreases[skill->mData.mAttribute]; // Play sound & skill progress notification diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index 9928966bb9..2dacee57b9 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -40,7 +40,8 @@ namespace MWMechanics for (std::vector<ESM::ENAMstruct>::const_iterator it = effects.begin(); it != effects.end(); ++it) { - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); + const ESM::MagicEffect* effect = + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(it->mEffectID); int _school = effect->mData.mSchool; int _skillLevel = stats.getSkill (spellSchoolToSkill(_school)).getModified(); @@ -61,7 +62,8 @@ namespace MWMechanics inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell.().find(spellId); return getSpellSchool(spell, actor); } @@ -107,7 +109,8 @@ namespace MWMechanics inline float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); return getSpellSuccessChance(spell, actor); } } From e628b23da6c57a29fb433af942622038629b3b45 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 21:45:18 +0400 Subject: [PATCH 128/255] applying new interface vol.3, inconsistent --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 49 +++++++++++-------- apps/openmw/mwdialogue/journalentry.cpp | 3 +- apps/openmw/mwdialogue/quest.cpp | 9 ++-- apps/openmw/mwsound/soundmanagerimp.cpp | 9 ++-- 4 files changed, 42 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 99aab62c4d..059c1ce88c 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -589,10 +589,14 @@ namespace MWDialogue mCompilerContext.setExtensions (&extensions); mDialogueMap.clear(); mActorKnownTopics.clear(); - MWWorld::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - for(MWWorld::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + + const MWWorld::Store<ESM::Dialogue> &dialogs = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); + + MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); + for (; it != dialogs.end(); ++it) { - mDialogueMap[toLower(it->first)] = it->second; + mDialogueMap[toLower(it->mId)] = *it; } } @@ -641,16 +645,17 @@ namespace MWDialogue //greeting bool greetingFound = false; - //MWWorld::RecListT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - MWWorld::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - for(MWWorld::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + const MWWorld::Store<ESM::Dialogue> &dialogs = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); + + MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); + for (; it != dialogs.end(); ++it) { - ESM::Dialogue ndialogue = it->second; - if(ndialogue.mType == ESM::Dialogue::Greeting) + if(it->mType == ESM::Dialogue::Greeting) { if (greetingFound) break; - for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin()); - iter!=it->second.mInfo.end(); ++iter) + for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); + iter!=it->mInfo.end(); ++iter) { if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) { @@ -664,7 +669,7 @@ namespace MWDialogue win->addText(iter->mResponse); executeScript(iter->mResultScript); greetingFound = true; - mLastTopic = it->first; + mLastTopic = it->mId; mLastDialogue = *iter; break; } @@ -741,22 +746,26 @@ namespace MWDialogue mChoice = -1; mActorKnownTopics.clear(); MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - MWWorld::RecListCaseT<ESM::Dialogue>::MapType dialogueList = MWBase::Environment::get().getWorld()->getStore().dialogs.list; - for(MWWorld::RecListCaseT<ESM::Dialogue>::MapType::iterator it = dialogueList.begin(); it!=dialogueList.end();it++) + + const MWWorld::Store<ESM::Dialogue> &dialogs = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); + + + MWWordl::Store<ESM::Dialogue>::iterator it = dialogs.begin(); + for (; it != dialogs.end(); ++it) { - ESM::Dialogue ndialogue = it->second; - if(ndialogue.mType == ESM::Dialogue::Topic) + if(it->mType == ESM::Dialogue::Topic) { - for (std::vector<ESM::DialInfo>::const_iterator iter (it->second.mInfo.begin()); - iter!=it->second.mInfo.end(); ++iter) + for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); + iter!=it->mInfo.end(); ++iter) { if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { - mActorKnownTopics.push_back(toLower(it->first)); + mActorKnownTopics.push_back(toLower(it->mId)); //does the player know the topic? - if(mKnownTopics.find(toLower(it->first)) != mKnownTopics.end()) + if(mKnownTopics.find(toLower(it->mId)) != mKnownTopics.end()) { - keywordList.push_back(it->first); + keywordList.push_back(it->mId); break; } } diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index fb982d34fd..df9129b4d5 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -35,7 +35,8 @@ namespace MWDialogue std::string JournalEntry::idFromIndex (const std::string& topic, int index) { - const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (topic); + const ESM::Dialogue *dialogue = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (topic); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) diff --git a/apps/openmw/mwdialogue/quest.cpp b/apps/openmw/mwdialogue/quest.cpp index 09feab8f98..5e2739be16 100644 --- a/apps/openmw/mwdialogue/quest.cpp +++ b/apps/openmw/mwdialogue/quest.cpp @@ -18,7 +18,8 @@ namespace MWDialogue const std::string Quest::getName() const { - const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic); + const ESM::Dialogue *dialogue = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) @@ -35,7 +36,8 @@ namespace MWDialogue void Quest::setIndex (int index) { - const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (mTopic); + const ESM::Dialogue *dialogue = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (mTopic); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) @@ -63,7 +65,8 @@ namespace MWDialogue { int index = -1; - const ESM::Dialogue *dialogue = MWBase::Environment::get().getWorld()->getStore().dialogs.find (entry.mTopic); + const ESM::Dialogue *dialogue = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>().find (entry.mTopic); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index 25a373aea4..8c4798c9d7 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -116,9 +116,8 @@ namespace MWSound std::string SoundManager::lookup(const std::string &soundId, float &volume, float &min, float &max) { - const ESM::Sound *snd = MWBase::Environment::get().getWorld()->getStore().sounds.search(soundId); - if(snd == NULL) - throw std::runtime_error(std::string("Failed to lookup sound ")+soundId); + const ESM::Sound *snd = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Sound>().find(soundId); volume *= pow(10.0, (snd->mData.mVolume/255.0*3348.0 - 3348.0) / 2000.0); @@ -424,7 +423,9 @@ namespace MWSound total = 0; } - const ESM::Region *regn = MWBase::Environment::get().getWorld()->getStore().regions.search(regionName); + const ESM::Region *regn = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(regionName); + if (regn == NULL) return; From 11567663a736c096b63437b03a29922bc2bf6757 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 22:34:08 +0400 Subject: [PATCH 129/255] applying new interface vol.4, inconsistent --- apps/openmw/mwscript/cellextensions.cpp | 2 +- apps/openmw/mwscript/compilercontext.cpp | 43 +++++++++++---------- apps/openmw/mwscript/guiextensions.cpp | 30 ++++++++++---- apps/openmw/mwscript/interpretercontext.cpp | 12 +++--- apps/openmw/mwscript/statsextensions.cpp | 4 +- apps/openmw/mwworld/store.hpp | 8 ++-- 6 files changed, 58 insertions(+), 41 deletions(-) diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index e2608e7c3d..a4a738ca76 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -109,7 +109,7 @@ namespace MWScript if (!(cell->mData.mFlags & ESM::Cell::Interior) && current.empty()) { const ESM::Region *region = - MWBase::Environment::get().getWorld()->getStore().regions.find (cell->mRegion); + MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().find (cell->mRegion); current = region->mName; } diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index 8756fb6330..d568cab219 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -42,26 +42,29 @@ namespace MWScript bool CompilerContext::isId (const std::string& name) const { + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + return - MWBase::Environment::get().getWorld()->getStore().activators.search (name) || - MWBase::Environment::get().getWorld()->getStore().potions.search (name) || - MWBase::Environment::get().getWorld()->getStore().appas.search (name) || - MWBase::Environment::get().getWorld()->getStore().armors.search (name) || - MWBase::Environment::get().getWorld()->getStore().books.search (name) || - MWBase::Environment::get().getWorld()->getStore().clothes.search (name) || - MWBase::Environment::get().getWorld()->getStore().containers.search (name) || - MWBase::Environment::get().getWorld()->getStore().creatures.search (name) || - MWBase::Environment::get().getWorld()->getStore().doors.search (name) || - MWBase::Environment::get().getWorld()->getStore().ingreds.search (name) || - MWBase::Environment::get().getWorld()->getStore().creatureLists.search (name) || - MWBase::Environment::get().getWorld()->getStore().itemLists.search (name) || - MWBase::Environment::get().getWorld()->getStore().lights.search (name) || - MWBase::Environment::get().getWorld()->getStore().lockpicks.search (name) || - MWBase::Environment::get().getWorld()->getStore().miscItems.search (name) || - MWBase::Environment::get().getWorld()->getStore().npcs.search (name) || - MWBase::Environment::get().getWorld()->getStore().probes.search (name) || - MWBase::Environment::get().getWorld()->getStore().repairs.search (name) || - MWBase::Environment::get().getWorld()->getStore().statics.search (name) || - MWBase::Environment::get().getWorld()->getStore().weapons.search (name); + store.get<ESM::Activator>().search (name) || + store.get<ESM::Potion>().search (name) || + store.get<ESM::Apparatus>().search (name) || + store.get<ESM::Armor>().search (name) || + store.get<ESM::Book>().search (name) || + store.get<ESM::Cloth>().search (name) || + store.get<ESM::Container>().search (name) || + store.get<ESM::Creature>().search (name) || + store.get<ESM::Door>().search (name) || + store.get<ESM::Ingredient>().search (name) || + store.get<ESM::CreatureLevList>().search (name) || + store.get<ESM::ItemLevList>().search (name) || + store.get<ESM::Light>().search (name) || + store.get<ESM::Tool>().search (name) || + store.get<ESM::Miscellaneous>().search (name) || + store.get<ESM::NPC>().search (name) || + store.get<ESM::Probe>().search (name) || + store.get<ESM::Repair>().search (name) || + store.get<ESM::Static>().search (name) || + store.get<ESM::Weapon>().search (name); } } diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 1eaac5d5f9..72c2db164f 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -108,13 +108,20 @@ namespace MWScript // "Will match complete or partial cells, so ShowMap, "Vivec" will show cells Vivec and Vivec, Fred's House as well." // http://www.uesp.net/wiki/Tes3Mod:ShowMap - const MWWorld::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; - for (MWWorld::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + const MWWorld::Store<ESM::Cell> &cells = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Cell>(); + + MWWorld::Store<ESM::Cell>::iterator it = cells.extBegin(); + for (; it != cells.extEnd(); ++it) { - std::string name = it->second->mName; + std::string name = it->mName; boost::algorithm::to_lower(name); if (name.find(cell) != std::string::npos) - MWBase::Environment::get().getWindowManager()->addVisitedLocation (it->second->mName, it->first.first, it->first.second); + MWBase::Environment::get().getWindowManager()->addVisitedLocation ( + it->mName, + it->getGridX(), + it->getGridY() + ); } } }; @@ -125,12 +132,19 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { - const MWWorld::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; - for (MWWorld::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + const MWWorld::Store<ESM::Cell> &cells = + MWBase::Environment::get().getWorld ()->getStore().get<ESM::Cell>(); + + MWWorld::Store<ESM::Cell>::iterator it = cells.extBegin(); + for (; it != cells.extEnd(); ++it) { - std::string name = it->second->mName; + std::string name = it->mName; if (name != "") - MWBase::Environment::get().getWindowManager()->addVisitedLocation (name, it->first.first, it->first.second); + MWBase::Environment::get().getWindowManager()->addVisitedLocation ( + name, + it->getGridX(), + it->getGridY() + ); } } }; diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index d5159eb7da..577ad008f5 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -278,7 +278,7 @@ namespace MWScript int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId)); return ptr.getRefData().getLocals().mShorts[index]; } @@ -291,7 +291,7 @@ namespace MWScript int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId)); return ptr.getRefData().getLocals().mLongs[index]; } @@ -304,7 +304,7 @@ namespace MWScript int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId)); return ptr.getRefData().getLocals().mFloats[index]; } @@ -317,7 +317,7 @@ namespace MWScript int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 's'); ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId)); ptr.getRefData().getLocals().mShorts[index] = value; } @@ -330,7 +330,7 @@ namespace MWScript int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'l'); ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId)); ptr.getRefData().getLocals().mLongs[index] = value; } @@ -343,7 +343,7 @@ namespace MWScript int index = MWBase::Environment::get().getScriptManager()->getLocalIndex (scriptId, name, 'f'); ptr.getRefData().setLocals ( - *MWBase::Environment::get().getWorld()->getStore().scripts.find (scriptId)); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptId)); ptr.getRefData().getLocals().mFloats[index] = value; } diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 8edad37eea..0c4c6d144f 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -328,7 +328,7 @@ namespace MWScript assert (ref); const ESM::Class& class_ = - *MWBase::Environment::get().getWorld()->getStore().classes.find (ref->mBase->mClass); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find (ref->mBase->mClass); float level = 0; float progress = std::modf (stats.getSkill (mIndex).getBase(), &level); @@ -390,7 +390,7 @@ namespace MWScript runtime.pop(); // make sure a spell with this ID actually exists. - MWBase::Environment::get().getWorld()->getStore().spells.find (id); + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (id); MWWorld::Class::get (ptr).getCreatureStats (ptr).getSpells().add (id); } diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 8f88a16a71..af1fae9a76 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -473,19 +473,19 @@ namespace MWWorld } } - iterator interiorsBegin() const { + iterator intBegin() const { return iterator(mSharedInt.begin()); } - iterator interiorsEnd() const { + iterator intEnd() const { return iterator(mSharedInt.end()); } - iterator exteriorsBegin() const { + iterator extBegin() const { return iterator(mSharedExt.begin()); } - iterator exteriorsEnd() const { + iterator extEnd() const { return iterator(mSharedExt.end()); } From aaf1b66c7ea47002b1110441b88bac435245d4d4 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Mon, 5 Nov 2012 19:53:55 +0100 Subject: [PATCH 130/255] BarterOffer is used in other trading services too --- apps/openmw/mwgui/spellbuyingwindow.cpp | 2 ++ apps/openmw/mwgui/spellcreationdialog.cpp | 3 ++- apps/openmw/mwgui/tradewindow.cpp | 8 +++++--- apps/openmw/mwgui/trainingwindow.cpp | 3 ++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index ece19cdc38..0e7925e28f 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -8,6 +8,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/manualref.hpp" @@ -51,6 +52,7 @@ namespace MWGui { const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); int price = spell->mData.mCost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); + price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>( diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 4ce0560108..3abd4c31e8 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -9,6 +9,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/player.hpp" #include "../mwworld/class.hpp" @@ -388,7 +389,7 @@ namespace MWGui float fSpellMakingValueMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellMakingValueMult")->getFloat(); /// \todo mercantile - int price = int(y) * fSpellMakingValueMult; + int price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,int(y) * fSpellMakingValueMult,true); mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price))); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 64710c2794..cd66b46f51 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -6,6 +6,7 @@ #include "../mwbase/world.hpp" #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/manualref.hpp" @@ -318,16 +319,17 @@ namespace MWGui { /// \todo price adjustment depending on merchantile skill - mCurrentBalance -= MWWorld::Class::get(item).getValue(item) * count; + mCurrentBalance -= MWWorld::Class::get(item).getValue(item) * count + + MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); updateLabels(); } void TradeWindow::buyFromNpc(MWWorld::Ptr item, int count) { - /// \todo price adjustment depending on merchantile skill - mCurrentBalance += MWWorld::Class::get(item).getValue(item) * count; + mCurrentBalance += MWWorld::Class::get(item).getValue(item) * count + - MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); updateLabels(); } diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index af61b3487b..106df627e2 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -7,6 +7,7 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/player.hpp" @@ -76,7 +77,7 @@ namespace MWGui for (int i=0; i<3; ++i) { /// \todo mercantile skill - int price = pcStats.getSkill (bestSkills[i].first).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); + int price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (),true); std::string skin = (price > mWindowManager.getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton"; From 9ebe9cb40c3f23a195e783f4edf736c9e0f3defe Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Mon, 5 Nov 2012 19:55:06 +0100 Subject: [PATCH 131/255] Disposition is now calculated according to the Wiki. But: bouty and deacease are not implemented (for disposition at least), and there is still no temporary/permanent dispositons changes --- apps/openmw/mwgui/dialogue.cpp | 5 +- .../mwmechanics/mechanicsmanagerimp.cpp | 89 ++++++++++++++----- 2 files changed, 72 insertions(+), 22 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 23d2197b70..9725df7fe6 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -12,6 +12,7 @@ #include "../mwbase/dialoguemanager.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "dialogue_history.hpp" #include "widgets.hpp" @@ -294,9 +295,9 @@ void DialogueWindow::updateOptions() mHistory->eraseText(0, mHistory->getTextLength()); mDispositionBar->setProgressRange(100); - mDispositionBar->setProgressPosition(40); + mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); mDispositionText->eraseText(0, mDispositionText->getTextLength()); - mDispositionText->addText("#B29154"+std::string("40/100")+"#B29154"); + mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154"); } void DialogueWindow::goodbye() diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 9a3ff610be..7f4ab600f2 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -325,22 +325,71 @@ namespace MWMechanics mUpdatePlayer = true; } - float min(float a,float b) + std::string toLower (const std::string& name) { - if(a<b) return a; - else return b; - } + std::string lowerCase; - float max(float a,float b) - { - if(a>b) return a; - else return b; + std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + return lowerCase; } int MechanicsManager::disposition(const MWWorld::Ptr& ptr) { MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); - return npcSkill.getDisposition(); + float x = npcSkill.getDisposition(); + + MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>(); + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>(); + MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); + MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); + + if (toLower(npc->base->mRace) == toLower(player->base->mRace)) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispRaceMod")->getFloat(); + + x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispPersonalityMult")->getFloat() + * (playerStats.getAttribute(ESM::Attribute::Personality).getModified() - MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispPersonalityBase")->getFloat()); + + float reaction = 0; + int rank = 0; + std::string npcFaction = npcSkill.getFactionRanks().begin()->first; + const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + + if (playerSkill.getFactionRanks().find(toLower(npcFaction)) != playerSkill.getFactionRanks().end()) + { + for(std::vector<ESM::Faction::Reaction>::const_iterator it = store.factions.find(toLower(npcFaction))->mReactions.begin();it != store.factions.find(toLower(npcFaction))->mReactions.end();it++) + { + if(toLower(it->mFaction) == toLower(npcFaction)) reaction = it->mReaction; + } + rank = playerSkill.getFactionRanks().find(toLower(npcFaction))->second; + } + else if (npcFaction != "") + { + std::cout << "npc has a faction!"; + for(std::vector<ESM::Faction::Reaction>::const_iterator it = store.factions.find(toLower(npcFaction))->mReactions.begin();it != store.factions.find(toLower(npcFaction))->mReactions.end();it++) + { + if(playerSkill.getFactionRanks().find(toLower(it->mFaction)) != playerSkill.getFactionRanks().end() ) + { + if(it->mReaction<reaction) reaction = it->mReaction; + } + } + rank = 0; + } + else + { + reaction = 0; + rank = 0; + } + x += (MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionRankMult")->getFloat() * rank + + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionRankBase")->getFloat()) + * MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionMod")->getFloat() * reaction; + //x -= MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispCrimeMod") * pcBounty; + //if (pc has a disease) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispDiseaseMod"); + if (playerSkill.getDrawState() == MWMechanics::DrawState_::DrawState_Weapon) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispWeaponDrawn")->getFloat(); + + int effective_disposition = std::max(0,std::min(int(x),100));//, normally clamped to [0..100] when used + return effective_disposition; } int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) @@ -352,13 +401,13 @@ namespace MWMechanics MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); - int clampedDisposition = min(disposition(ptr),100); - float a = min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); - float b = min(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); - float c = min(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); - float d = min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); - float e = min(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); - float f = min(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + int clampedDisposition = std::min(disposition(ptr),100); + float a = std::min<float>(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float b = std::min<float>(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float c = std::min<float>(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + float d = std::min<float>(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float e = std::min<float>(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float f = std::min<float>(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm(); float npcTerm = (d + e + f) * sellerStats.getFatigueTerm(); @@ -367,13 +416,13 @@ namespace MWMechanics float x; if(buying) x = buyTerm; - else x = min(buyTerm, sellTerm); - std::cout << "x" << x; + else x = std::min(buyTerm, sellTerm); + //std::cout << "x" << x; int offerPrice; if (x < 1) offerPrice = int(x * basePrice); if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice); - offerPrice = max(1, offerPrice); - std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n"; + offerPrice = std::max(1, offerPrice); + //std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n"; return offerPrice; } } From 7a7825577a8a6ee674a29cc605d9b2ad8075f160 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Mon, 5 Nov 2012 18:40:02 +0000 Subject: [PATCH 132/255] Changed: use MWWorld::Ptr for PhysicsSystem arguments --- apps/openmw/mwclass/activator.cpp | 7 ++-- apps/openmw/mwclass/apparatus.cpp | 5 +-- apps/openmw/mwclass/armor.cpp | 5 +-- apps/openmw/mwclass/book.cpp | 5 +-- apps/openmw/mwclass/clothing.cpp | 5 +-- apps/openmw/mwclass/container.cpp | 5 +-- apps/openmw/mwclass/creature.cpp | 5 +-- apps/openmw/mwclass/door.cpp | 5 +-- apps/openmw/mwclass/ingredient.cpp | 5 +-- apps/openmw/mwclass/light.cpp | 9 ++--- apps/openmw/mwclass/lockpick.cpp | 5 +-- apps/openmw/mwclass/misc.cpp | 5 +-- apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwclass/potion.cpp | 5 +-- apps/openmw/mwclass/probe.cpp | 5 +-- apps/openmw/mwclass/repair.cpp | 5 +-- apps/openmw/mwclass/static.cpp | 5 +-- apps/openmw/mwclass/weapon.cpp | 5 +-- apps/openmw/mwworld/physicssystem.cpp | 58 ++++++++++----------------- apps/openmw/mwworld/physicssystem.hpp | 17 +++----- apps/openmw/mwworld/worldimp.cpp | 46 ++++++++++++--------- 21 files changed, 93 insertions(+), 121 deletions(-) diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index e815549d8e..1f5c7c2174 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -30,9 +30,8 @@ namespace MWClass void Activator::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Activator::getModel(const MWWorld::Ptr &ptr) const @@ -94,7 +93,7 @@ namespace MWClass return info; } - + MWWorld::Ptr Activator::copyToCellImpl(const MWWorld::Ptr &ptr, MWWorld::CellStore &cell) const { diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index a05c24e864..7205ab3955 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -33,9 +33,8 @@ namespace MWClass void Apparatus::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Apparatus::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 7254c37f8a..906d880709 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -36,9 +36,8 @@ namespace MWClass void Armor::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Armor::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index 4a2ad1dcb9..b994634d86 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -32,9 +32,8 @@ namespace MWClass void Book::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Book::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index d746350dfe..c902e8e8f0 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -34,9 +34,8 @@ namespace MWClass void Clothing::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Clothing::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 237f451f33..0d75b653d7 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -65,9 +65,8 @@ namespace MWClass void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Container::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index e4ff3c95ba..fce9511165 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -94,9 +94,8 @@ namespace MWClass void Creature::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()){ - physics.insertActorPhysics(ptr, model); - } + if(!model.empty()) + physics.addActor(ptr); MWBase::Environment::get().getMechanicsManager()->addActor (ptr); } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f944391e12..b03db4ec7d 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -35,9 +35,8 @@ namespace MWClass void Door::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Door::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 45779287f4..e322fa3b8f 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -41,9 +41,8 @@ namespace MWClass void Ingredient::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Ingredient::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 6ae9ed6615..fc545abaf8 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -53,12 +53,11 @@ namespace MWClass const std::string &model = ref->base->mModel; - if(!model.empty()) { - physics.insertObjectPhysics(ptr, "meshes\\" + model); - } - if (!ref->base->mSound.empty()) { + if(!model.empty()) + physics.addObject(ptr); + + if (!ref->base->mSound.empty()) MWBase::Environment::get().getSoundManager()->playSound3D(ptr, ref->base->mSound, 1.0, 1.0, MWBase::SoundManager::Play_Loop); - } } std::string Light::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index a0ec65c988..71e2dbb12f 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -34,9 +34,8 @@ namespace MWClass void Lockpick::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Lockpick::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index edcfc7daa7..ca7e073b1e 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -37,9 +37,8 @@ namespace MWClass void Miscellaneous::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Miscellaneous::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 2e21f8f63f..7e554ee8af 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -138,7 +138,7 @@ namespace MWClass void Npc::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { - physics.insertActorPhysics(ptr, getModel(ptr)); + physics.addActor(ptr); MWBase::Environment::get().getMechanicsManager()->addActor(ptr); } diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index f641cc7199..6403765366 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -34,9 +34,8 @@ namespace MWClass void Potion::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Potion::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 39472f2ec4..8961b8007f 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -34,9 +34,8 @@ namespace MWClass void Probe::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Probe::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 7ccb34913d..3c0361b0be 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -32,9 +32,8 @@ namespace MWClass void Repair::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Repair::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index 07ab54256e..099b096572 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -24,9 +24,8 @@ namespace MWClass void Static::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Static::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index fee0dfdf14..52dc91205d 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -34,9 +34,8 @@ namespace MWClass void Weapon::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics) const { const std::string model = getModel(ptr); - if(!model.empty()) { - physics.insertObjectPhysics(ptr, model); - } + if(!model.empty()) + physics.addObject(ptr); } std::string Weapon::getModel(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 3be85c7f3d..5359c4eb27 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -12,6 +12,7 @@ #include <components/nifbullet/bullet_nif_loader.hpp> //#include "../mwbase/world.hpp" // FIXME +#include "../mwbase/environment.hpp" #include "ptr.hpp" #include "class.hpp" @@ -249,31 +250,36 @@ namespace MWWorld mEngine->removeHeightField(x, y); } - void PhysicsSystem::addObject (const std::string& handle, const std::string& mesh, - const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position) + void PhysicsSystem::addObject (const Ptr& ptr) { - handleToMesh[handle] = mesh; - OEngine::Physic::RigidBody* body = mEngine->createAndAdjustRigidBody(mesh,handle,scale, position, rotation); + std::string mesh = MWWorld::Class::get(ptr).getModel(ptr); + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + handleToMesh[node->getName()] = mesh; + OEngine::Physic::RigidBody* body = mEngine->createAndAdjustRigidBody(mesh, node->getName(), node->getScale().x, node->getPosition(), node->getOrientation()); mEngine->addRigidBody(body); } - void PhysicsSystem::addActor (const std::string& handle, const std::string& mesh, - const Ogre::Vector3& position, float scale, const Ogre::Quaternion& rotation) + void PhysicsSystem::addActor (const Ptr& ptr) { + std::string mesh = MWWorld::Class::get(ptr).getModel(ptr); + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); //TODO:optimize this. Searching the std::map isn't very efficient i think. - mEngine->addCharacter(handle, mesh, position, scale, rotation); + mEngine->addCharacter(node->getName(), mesh, node->getPosition(), node->getScale().x, node->getOrientation()); } void PhysicsSystem::removeObject (const std::string& handle) { //TODO:check if actor??? + mEngine->removeCharacter(handle); mEngine->removeRigidBody(handle); mEngine->deleteRigidBody(handle); } - void PhysicsSystem::moveObject (const std::string& handle, Ogre::SceneNode* node) + void PhysicsSystem::moveObject (const Ptr& ptr) { + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + std::string handle = node->getName(); Ogre::Vector3 position = node->getPosition(); if (OEngine::Physic::RigidBody* body = mEngine->getRigidBody(handle)) { @@ -307,8 +313,10 @@ namespace MWWorld } } - void PhysicsSystem::rotateObject (const std::string& handle, Ogre::SceneNode* node) + void PhysicsSystem::rotateObject (const Ptr& ptr) { + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + std::string handle = node->getName(); Ogre::Quaternion rotation = node->getOrientation(); if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) { @@ -324,23 +332,18 @@ namespace MWWorld } } - void PhysicsSystem::scaleObject (const std::string& handle, Ogre::SceneNode* node) + void PhysicsSystem::scaleObject (const Ptr& ptr) { + Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); + std::string handle = node->getName(); if(handleToMesh.find(handle) != handleToMesh.end()) { removeObject(handle); - - float scale = node->getScale().x; - Ogre::Quaternion quat = node->getOrientation(); - Ogre::Vector3 vec = node->getPosition(); - addObject(handle, handleToMesh[handle], quat, scale, vec); + addObject(ptr); } if (OEngine::Physic::PhysicActor* act = mEngine->getCharacter(handle)) - { - float scale = node->getScale().x; - act->setScale(scale); - } + act->setScale(node->getScale().x); } bool PhysicsSystem::toggleCollisionMode() @@ -371,23 +374,6 @@ namespace MWWorld throw std::logic_error ("can't find player"); } - void PhysicsSystem::insertObjectPhysics(const MWWorld::Ptr& ptr, const std::string model){ - - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - - addObject( - node->getName(), - model, - node->getOrientation(), - node->getScale().x, - node->getPosition()); - } - - void PhysicsSystem::insertActorPhysics(const MWWorld::Ptr& ptr, const std::string model){ - Ogre::SceneNode* node = ptr.getRefData().getBaseNode(); - addActor (node->getName(), model, node->getPosition(), node->getScale().x, node->getOrientation()); - } - bool PhysicsSystem::getObjectAABB(const MWWorld::Ptr &ptr, Ogre::Vector3 &min, Ogre::Vector3 &max) { std::string model = MWWorld::Class::get(ptr).getModel(ptr); diff --git a/apps/openmw/mwworld/physicssystem.hpp b/apps/openmw/mwworld/physicssystem.hpp index 1427060f6a..8bd73fd6cb 100644 --- a/apps/openmw/mwworld/physicssystem.hpp +++ b/apps/openmw/mwworld/physicssystem.hpp @@ -20,11 +20,9 @@ namespace MWWorld std::vector< std::pair<std::string, Ogre::Vector3> > doPhysicsFixed (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors); ///< do physics with fixed timestep - Usage: first call doPhysics with frame dt, then call doPhysicsFixed as often as time steps have passed - void addObject (const std::string& handle, const std::string& mesh, - const Ogre::Quaternion& rotation, float scale, const Ogre::Vector3& position); + void addObject (const MWWorld::Ptr& ptr); - void addActor (const std::string& handle, const std::string& mesh, - const Ogre::Vector3& position, float scale, const Ogre::Quaternion& rotation); + void addActor (const MWWorld::Ptr& ptr); void addHeightField (float* heights, int x, int y, float yoffset, @@ -32,13 +30,14 @@ namespace MWWorld void removeHeightField (int x, int y); + // have to keep this as handle for now as unloadcell only knows scenenode names void removeObject (const std::string& handle); - void moveObject (const std::string& handle, Ogre::SceneNode* node); + void moveObject (const MWWorld::Ptr& ptr); - void rotateObject (const std::string& handle, Ogre::SceneNode* node); + void rotateObject (const MWWorld::Ptr& ptr); - void scaleObject (const std::string& handle, Ogre::SceneNode* node); + void scaleObject (const MWWorld::Ptr& ptr); bool toggleCollisionMode(); @@ -60,10 +59,6 @@ namespace MWWorld std::pair<bool, Ogre::Vector3> castRay(float mouseX, float mouseY); ///< cast ray from the mouse, return true if it hit something and the first result (in OGRE coordinates) - void insertObjectPhysics(const MWWorld::Ptr& ptr, std::string model); - - void insertActorPhysics(const MWWorld::Ptr&, std::string model); - OEngine::Physic::PhysicEngine* getEngine(); void setCurrentWater(bool hasWater, int waterHeight); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 7b938be5e2..81fe14ba89 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -191,7 +191,8 @@ namespace MWWorld std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player //We will need to support the 1st person file too in the future - mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), playerCollisionFile, Ogre::Vector3 (0, 0, 0), 1, Ogre::Quaternion::ZERO); + mPhysics->addActor(mPlayer->getPlayer()); +// mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), playerCollisionFile, Ogre::Vector3 (0, 0, 0), 1, Ogre::Quaternion::ZERO); // global variables mGlobalVariables = new Globals (mStore); @@ -582,39 +583,48 @@ namespace MWWorld CellStore *currCell = ptr.getCell(); bool isPlayer = ptr == mPlayer->getPlayer(); bool haveToMove = mWorldScene->isCellActive(*currCell) || isPlayer; - if (*currCell != newCell) { - if (isPlayer) { - if (!newCell.isExterior()) { + if (*currCell != newCell) + { + if (isPlayer) + if (!newCell.isExterior()) changeToInteriorCell(toLower(newCell.cell->mName), pos); - } else { + else + { int cellX = newCell.cell->mData.mX; int cellY = newCell.cell->mData.mY; mWorldScene->changeCell(cellX, cellY, pos, false); } - } else { - if (!mWorldScene->isCellActive(*currCell)) { + else { + if (!mWorldScene->isCellActive(*currCell)) copyObjectToCell(ptr, newCell, pos); - } else if (!mWorldScene->isCellActive(newCell)) { + else if (!mWorldScene->isCellActive(newCell)) + { MWWorld::Class::get(ptr).copyToCell(ptr, newCell); mWorldScene->removeObjectFromScene(ptr); mLocalScripts.remove(ptr); haveToMove = false; - } else { + } + else + { MWWorld::Ptr copy = MWWorld::Class::get(ptr).copyToCell(ptr, newCell); mRendering->moveObjectToCell(copy, vec, currCell); - if (MWWorld::Class::get(ptr).isActor()) { + if (MWWorld::Class::get(ptr).isActor()) + { MWBase::MechanicsManager *mechMgr = MWBase::Environment::get().getMechanicsManager(); mechMgr->removeActor(ptr); mechMgr->addActor(copy); - } else { + } + else + { std::string script = MWWorld::Class::get(ptr).getScript(ptr); - if (!script.empty()) { + if (!script.empty()) + { mLocalScripts.remove(ptr); mLocalScripts.add(script, copy); } @@ -623,9 +633,10 @@ namespace MWWorld ptr.getRefData().setCount(0); } } - if (haveToMove) { + if (haveToMove) + { mRendering->moveObject(ptr, vec); - mPhysics->moveObject (ptr.getRefData().getHandle(), ptr.getRefData().getBaseNode()); + mPhysics->moveObject (ptr); } } @@ -657,7 +668,7 @@ namespace MWWorld ptr.getCellRef().mScale = scale; //scale = scale/ptr.getRefData().getBaseNode()->getScale().x; ptr.getRefData().getBaseNode()->setScale(scale,scale,scale); - mPhysics->scaleObject( ptr.getRefData().getHandle(), ptr.getRefData().getBaseNode()); + mPhysics->scaleObject(ptr); } void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust) @@ -673,10 +684,7 @@ namespace MWWorld if (ptr.getRefData().getBaseNode() != 0) { - mPhysics->rotateObject( - ptr.getRefData().getHandle(), - ptr.getRefData().getBaseNode() - ); + mPhysics->rotateObject(ptr); } } From 42aae566a71ed1d21a3585bc9af56348559f4a32 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Mon, 5 Nov 2012 23:41:26 +0400 Subject: [PATCH 133/255] applying new interface vol.5, inconsistent --- apps/openmw/mwgui/class.cpp | 16 +++++------ apps/openmw/mwgui/container.cpp | 5 +++- apps/openmw/mwgui/hud.cpp | 8 ++++-- apps/openmw/mwgui/levelupdialog.cpp | 11 +++++--- apps/openmw/mwgui/spellcreationdialog.cpp | 34 ++++++++++++++++------- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 40805c77e8..461604b765 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -50,7 +50,7 @@ void GenerateClassResultDialog::setClassId(const std::string &classId) { mCurrentClassId = classId; mClassImage->setImageTexture(std::string("textures\\levelup\\") + mCurrentClassId + ".dds"); - mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().classes.find(mCurrentClassId)->mName); + mClassName->setCaption(MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mCurrentClassId)->mName); } // widget controls @@ -187,18 +187,16 @@ void PickClassDialog::updateClasses() const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - MWWorld::RecListT<ESM::Class>::MapType::const_iterator it = store.classes.list.begin(); - MWWorld::RecListT<ESM::Class>::MapType::const_iterator end = store.classes.list.end(); int index = 0; - for (; it != end; ++it) + MWWorld::Store<ESM::Cell>::iterator it = store.get<ESM::Cell>().begin(); + for (; it != store.get<ESM::Cell>().end(); ++it) { - const ESM::Class &klass = it->second; - bool playable = (klass.mData.mIsPlayable != 0); + bool playable = (it->mData.mIsPlayable != 0); if (!playable) // Only display playable classes continue; - const std::string &id = it->first; - mClassList->addItem(klass.mName, id); + const std::string &id = it->mId; + mClassList->addItem(it->mName, id); if (boost::iequals(id, mCurrentClassId)) mClassList->setIndexSelected(index); ++index; @@ -210,7 +208,7 @@ void PickClassDialog::updateStats() if (mCurrentClassId.empty()) return; const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Class *klass = store.classes.search(mCurrentClassId); + const ESM::Class *klass = store.get<ESM::Class>().search(mCurrentClassId); if (!klass) return; diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index ff94e5151b..db286a7fca 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -127,10 +127,13 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender) if (isInventory()) { + const MWWorld::Store<ESM::GameSetting> &gmst = + MWWorld::Environment::get().getWorld()->getStore()->get<ESM::GameSetting>(); + // the player is trying to sell an item, check if the merchant accepts it // also, don't allow selling gold (let's be better than Morrowind at this, can we?) if (!MWBase::Environment::get().getWindowManager()->getTradeWindow()->npcAcceptsItem(object) || - MWWorld::Class::get(object).getName(object) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + MWWorld::Class::get(object).getName(object) == gmst.find("sGold")->getString()) { // user notification "i don't buy this item" MWBase::Environment::get().getWindowManager()-> diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp index 66cc6b21ad..9b4075f576 100644 --- a/apps/openmw/mwgui/hud.cpp +++ b/apps/openmw/mwgui/hud.cpp @@ -341,7 +341,9 @@ void HUD::onResChange(int width, int height) void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); + std::string spellName = spell->mName; if (spellName != mSpellName && mSpellVisible) { @@ -361,7 +363,9 @@ void HUD::setSelectedSpell(const std::string& spellId, int successChancePercent) mSpellBox->setUserString("Spell", spellId); // use the icon of the first effect - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID); + const ESM::MagicEffect* effect = + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID); + std::string icon = effect->mIcon; int slashPos = icon.find("\\"); icon.insert(slashPos+1, "b_"); diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index afb4bb6214..399ff74a3a 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -123,11 +123,14 @@ namespace MWGui const ESM::Class& playerClass = MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); // retrieve the ID to this class std::string classId; - std::map<std::string, ESM::Class> list = MWBase::Environment::get().getWorld()->getStore ().classes.list; - for (std::map<std::string, ESM::Class>::iterator it = list.begin(); it != list.end(); ++it) + const MWWorld::Store<ESM::Class> &classes = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>(); + + MWWorld::Store<ESM::Class>::iterator it = classes.begin(); + for (; it != classes.end(); ++it) { - if (playerClass.mName == it->second.mName) - classId = it->first; + if (playerClass.mName == it->mName) + classId = it->mId; } mClassImage->setImageTexture ("textures\\levelup\\" + classId + ".dds"); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 6c45d2b3d9..32b7f934b4 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -28,8 +28,11 @@ namespace bool sortMagicEffects (short id1, short id2) { - return MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id1))->getString() - < MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find(ESM::MagicEffect::effectIdToString (id2))->getString(); + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + + return gmst.find(ESM::MagicEffect::effectIdToString (id1))->getString() + < gmst.find(ESM::MagicEffect::effectIdToString (id2))->getString(); } } @@ -105,7 +108,8 @@ namespace MWGui void EditEffectDialog::editEffect (ESM::ENAMstruct effect) { - const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effect.mEffectID); + const ESM::MagicEffect* magicEffect = + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effect.mEffectID); setMagicEffect(magicEffect); @@ -358,16 +362,23 @@ namespace MWGui { float y = 0; + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it) { float x = 0.5 * it->mMagnMin + it->mMagnMax; - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(it->mEffectID); + const ESM::MagicEffect* effect = + store.get<ESM::MagicEffect>().find(it->mEffectID); + x *= 0.1 * effect->mData.mBaseCost; x *= 1 + it->mDuration; x += 0.05 * std::max(1, it->mArea) * effect->mData.mBaseCost; - float fEffectCostMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fEffectCostMult")->getFloat(); + float fEffectCostMult = + store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat(); + y += x * fEffectCostMult; y = std::max(1.f,y); @@ -384,7 +395,8 @@ namespace MWGui mMagickaCost->setCaption(boost::lexical_cast<std::string>(int(y))); - float fSpellMakingValueMult = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellMakingValueMult")->getFloat(); + float fSpellMakingValueMult = + store.get<ESM::GameSetting>().find("fSpellMakingValueMult")->getFloat(); /// \todo mercantile int price = int(y) * fSpellMakingValueMult; @@ -422,7 +434,8 @@ namespace MWGui for (MWMechanics::Spells::TIterator it = spells.begin(); it != spells.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(*it); // only normal spells count if (spell->mData.mType != ESM::Spell::ST_Spell) @@ -442,14 +455,14 @@ namespace MWGui for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) { - mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( + mAvailableEffectsList->addItem(MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find( ESM::MagicEffect::effectIdToString (*it))->getString()); } mAvailableEffectsList->adjustSize (); for (std::vector<short>::const_iterator it = knownEffects.begin(); it != knownEffects.end(); ++it) { - std::string name = MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find( + std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find( ESM::MagicEffect::effectIdToString (*it))->getString(); MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name); w->setUserData(*it); @@ -515,7 +528,8 @@ namespace MWGui } } - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(effectId); + const ESM::MagicEffect* effect = + MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(effectId); mAddEffectDialog.newEffect (effect); From 646e689239018f21709840672ba3b3507d9fd667 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Mon, 5 Nov 2012 20:47:28 +0100 Subject: [PATCH 134/255] clear name edits when opening alchemy / spell creation --- apps/openmw/mwgui/alchemywindow.cpp | 2 ++ apps/openmw/mwgui/dialogue.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.cpp | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/alchemywindow.cpp b/apps/openmw/mwgui/alchemywindow.cpp index 56db47a0f5..fc06e866c6 100644 --- a/apps/openmw/mwgui/alchemywindow.cpp +++ b/apps/openmw/mwgui/alchemywindow.cpp @@ -132,6 +132,8 @@ namespace MWGui openContainer (MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); // this sets mPtr setFilter (ContainerBase::Filter_Ingredients); + mNameEdit->setCaption(""); + mAlchemy.setAlchemist (mPtr); int index = 0; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 96b85b4c4c..c82513093c 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -170,7 +170,7 @@ void DialogueWindow::startDialogue(MWWorld::Ptr actor, std::string npcName) setTitle(npcName); mTopicsList->clear(); - mHistory->eraseText(0,mHistory->getTextLength()); + mHistory->setCaption(""); updateOptions(); } diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 4ce0560108..1aa20adae1 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -291,6 +291,7 @@ namespace MWGui void SpellCreationDialog::startSpellMaking (MWWorld::Ptr actor) { mPtr = actor; + mNameEdit->setCaption(""); startEditing(); } From e8e3c211a490fbf0400725adb1d2523d62e7c447 Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Mon, 5 Nov 2012 19:48:07 +0000 Subject: [PATCH 135/255] Changed: MWRender::player: make camera rotation functions public; world: fix/clean scaleObject and rotateObject; rendering: add scaleObject code, fix rotateObject so it stores correct rotation --- apps/openmw/mwrender/player.hpp | 20 +++++------ apps/openmw/mwrender/renderingmanager.cpp | 43 +++++++++++++---------- apps/openmw/mwworld/worldimp.cpp | 27 +++++++------- 3 files changed, 47 insertions(+), 43 deletions(-) diff --git a/apps/openmw/mwrender/player.hpp b/apps/openmw/mwrender/player.hpp index b4d8983e4e..29a68ca693 100644 --- a/apps/openmw/mwrender/player.hpp +++ b/apps/openmw/mwrender/player.hpp @@ -48,16 +48,6 @@ namespace MWRender /// Updates sound manager listener data void updateListener(); - void rotateCamera(const Ogre::Vector3 &rot, bool adjust); - - float getYaw(); - void setYaw(float angle); - - float getPitch(); - void setPitch(float angle); - - void compensateYaw(float diff); - void setLowHeight(bool low = true); public: @@ -69,7 +59,17 @@ namespace MWRender /// \param rot Rotation angles in radians /// \return true if player object needs to bo rotated physically bool rotate(const Ogre::Vector3 &rot, bool adjust); + + void rotateCamera(const Ogre::Vector3 &rot, bool adjust); + float getYaw(); + void setYaw(float angle); + + float getPitch(); + void setPitch(float angle); + + void compensateYaw(float diff); + std::string getHandle() const; /// Attach camera to object diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index bcc3a311d9..2daf990876 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -258,39 +258,44 @@ void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& setPosition (position); } -void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale){ - +void RenderingManager::scaleObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& scale) +{ + ptr.getRefData().getBaseNode()->setScale(scale); } -bool -RenderingManager::rotateObject( - const MWWorld::Ptr &ptr, - Ogre::Vector3 &rot, - bool adjust) +bool RenderingManager::rotateObject( const MWWorld::Ptr &ptr, Ogre::Vector3 &rot, bool adjust) { bool isActive = ptr.getRefData().getBaseNode() != 0; bool isPlayer = isActive && ptr.getRefData().getHandle() == "player"; bool force = true; - if (isPlayer) { + if (isPlayer) force = mPlayer->rotate(rot, adjust); - } + MWWorld::Class::get(ptr).adjustRotation(ptr, rot.x, rot.y, rot.z); - if (adjust) { + if (!isPlayer && isActive) + { + Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X); + Ogre::Quaternion yr(Ogre::Radian(rot.y), Ogre::Vector3::UNIT_Y); + Ogre::Quaternion zr(Ogre::Radian(rot.z), Ogre::Vector3::UNIT_Z); + Ogre::Quaternion newo = adjust ? (xr * yr * zr) * ptr.getRefData().getBaseNode()->getOrientation() : xr * yr * zr; + rot.x = newo.x; + rot.y = newo.y; + rot.z = newo.z; + ptr.getRefData().getBaseNode()->setOrientation(newo); + } + else if(isPlayer) + { + rot.x = mPlayer->getPitch(); + rot.z = mPlayer->getYaw(); + } + else if (adjust) + { /// \note Stored and passed in radians float *f = ptr.getRefData().getPosition().rot; rot.x += f[0], rot.y += f[1], rot.z += f[2]; } - - if (!isPlayer && isActive) { - Ogre::Quaternion xr(Ogre::Radian(rot.x), Ogre::Vector3::UNIT_X); - Ogre::Quaternion yr(Ogre::Radian(rot.y), Ogre::Vector3::UNIT_Y); - Ogre::Quaternion zr(Ogre::Radian(rot.z), Ogre::Vector3::UNIT_Z); - - ptr.getRefData().getBaseNode()->setOrientation(xr * yr * zr); - } - return force; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 81fe14ba89..58d2a9eac3 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -657,17 +657,16 @@ namespace MWWorld void World::moveObject (const Ptr& ptr, float x, float y, float z) { moveObjectImp(ptr, x, y, z); - - } void World::scaleObject (const Ptr& ptr, float scale) { MWWorld::Class::get(ptr).adjustScale(ptr,scale); - ptr.getCellRef().mScale = scale; - //scale = scale/ptr.getRefData().getBaseNode()->getScale().x; - ptr.getRefData().getBaseNode()->setScale(scale,scale,scale); + + if(ptr.getRefData().getBaseNode() == 0) + return; + mRendering->scaleObject(ptr, Vector3(scale,scale,scale)); mPhysics->scaleObject(ptr); } @@ -678,16 +677,16 @@ namespace MWWorld rot.y = Ogre::Degree(y).valueRadians(); rot.z = Ogre::Degree(z).valueRadians(); - if (mRendering->rotateObject(ptr, rot, adjust)) { - float *objRot = ptr.getRefData().getPosition().rot; - objRot[0] = rot.x, objRot[1] = rot.y, objRot[2] = rot.z; - - - if (ptr.getRefData().getBaseNode() != 0) { - mPhysics->rotateObject(ptr); - } - } + float *objRot = ptr.getRefData().getPosition().rot; + if(ptr.getRefData().getBaseNode() == 0 || !mRendering->rotateObject(ptr, rot, adjust)) + { + objRot[0] = (adjust ? objRot[0] + rot.x : rot.x), objRot[1] = (adjust ? objRot[1] + rot.y : rot.y), objRot[2] = (adjust ? objRot[2] + rot.z : rot.z); + return; + } + // do this after rendering rotated the object so it gets changed by Class->adjustRotation + objRot[0] = rot.x, objRot[1] = rot.y, objRot[2] = rot.z; + mPhysics->rotateObject(ptr); } void World::safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos) From 4637503680089c85ed8d1d46f423cf376fc5306a Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 00:34:11 +0400 Subject: [PATCH 136/255] applying new interface vol.6, inconsistent --- apps/openmw/mwgui/birth.cpp | 28 ++++++++++++++-------- apps/openmw/mwgui/charactercreation.cpp | 9 +++++-- apps/openmw/mwgui/console.cpp | 6 ++--- apps/openmw/mwgui/dialogue.cpp | 32 +++++++++++++++---------- apps/openmw/mwgui/race.cpp | 20 ++++++++-------- apps/openmw/mwgui/review.cpp | 8 +++++-- apps/openmw/mwgui/spellbuyingwindow.cpp | 11 ++++++--- apps/openmw/mwgui/widgets.cpp | 19 ++++++++++----- apps/openmw/mwworld/esmstore.hpp | 11 +++++++++ 9 files changed, 95 insertions(+), 49 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 2ccf96bc41..1891bf5500 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -130,19 +130,18 @@ void BirthDialog::updateBirths() { mBirthList->removeAllItems(); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::Store<ESM::BirthSign> &signs = + MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>(); - MWWorld::RecListT<ESM::BirthSign>::MapType::const_iterator it = store.birthSigns.list.begin(); - MWWorld::RecListT<ESM::BirthSign>::MapType::const_iterator end = store.birthSigns.list.end(); int index = 0; // sort by name std::vector < std::pair<std::string, const ESM::BirthSign*> > birthSigns; - for (; it!=end; ++it) + + MWWorld::Store<ESM::BirthSign>::iterator it = signs.begin(); + for (; it != signs.end(); ++it) { - std::string id = it->first; - const ESM::BirthSign* sign = &it->second; - birthSigns.push_back(std::make_pair(id, sign)); + birthSigns.push_back(std::make_pair(it->mId, &(*it))); } std::sort(birthSigns.begin(), birthSigns.end(), sortBirthSigns); @@ -170,8 +169,11 @@ void BirthDialog::updateSpells() const int lineHeight = 18; MyGUI::IntCoord coord(0, 0, mSpellArea->getWidth(), 18); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::BirthSign *birth = store.birthSigns.find(mCurrentBirthId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::BirthSign *birth = + store.get<ESM::BirthSign>().find(mCurrentBirthId); std::string texturePath = std::string("textures\\") + birth->mTexture; fixTexturePath(texturePath); @@ -200,11 +202,17 @@ void BirthDialog::updateSpells() } int i = 0; - struct{ const std::vector<std::string> &spells; const char *label; } categories[3] = { + + struct { + const std::vector<std::string> &spells; + const char *label; + } + categories[3] = { {abilities, "sBirthsignmenu1"}, {powers, "sPowers"}, {spells, "sBirthsignmenu2"} }; + for (int category = 0; category < 3; ++category) { if (!categories[category].spells.empty()) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index e4b77287c3..253e0779cb 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -357,7 +357,9 @@ void CharacterCreation::onPickClassDialogDone(WindowBase* parWindow) const std::string &classId = mPickClassDialog->getClassId(); if (!classId.empty()) MWBase::Environment::get().getMechanicsManager()->setPlayerClass(classId); - const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(classId); + + const ESM::Class *klass = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(classId); if (klass) { mPlayerClass = *klass; @@ -729,7 +731,10 @@ void CharacterCreation::onGenerateClassDone(WindowBase* parWindow) mGenerateClassResultDialog = 0; MWBase::Environment::get().getMechanicsManager()->setPlayerClass(mGenerateClass); - const ESM::Class *klass = MWBase::Environment::get().getWorld()->getStore().classes.find(mGenerateClass); + + const ESM::Class *klass = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(mGenerateClass); + mPlayerClass = *klass; mWM->setPlayerClass(mPlayerClass); diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 589a7abac3..9595f32842 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -92,10 +92,10 @@ namespace MWGui scanner.listKeywords (mNames); // identifier - const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& store = + MWBase::Environment::get().getWorld()->getStore(); - for (MWWorld::RecListList::const_iterator iter (store.recLists.begin()); - iter!=store.recLists.end(); ++iter) + for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it) { iter->second->listIdentifier (mNames); } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 66444e18c6..49804be2e0 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -127,33 +127,36 @@ void DialogueWindow::onSelectTopic(std::string topic) { if (!mEnabled) return; - if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString()) + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + + if (topic == gmst.find("sBarter")->getString()) { /// \todo check if the player is allowed to trade with this actor (e.g. faction rank high enough)? mWindowManager.pushGuiMode(GM_Barter); mWindowManager.getTradeWindow()->startTrade(mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()) + else if (topic == gmst.find("sSpells")->getString()) { mWindowManager.pushGuiMode(GM_SpellBuying); mWindowManager.getSpellBuyingWindow()->startSpellBuying(mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()) + else if (topic == gmst.find("sTravel")->getString()) { mWindowManager.pushGuiMode(GM_Travel); mWindowManager.getTravelWindow()->startTravel(mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellMakingMenuTitle")->getString()) + else if (topic == gmst.find("sSpellMakingMenuTitle")->getString()) { mWindowManager.pushGuiMode(GM_SpellCreation); mWindowManager.startSpellMaking (mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()) + else if (topic == gmst.find("sEnchanting")->getString()) { mWindowManager.pushGuiMode(GM_Enchanting); mWindowManager.startEnchanting (mPtr); } - else if (topic == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()) + else if (topic == gmst.find("sServiceTrainingTitle")->getString()) { mWindowManager.pushGuiMode(GM_Training); mWindowManager.startTraining (mPtr); @@ -180,23 +183,26 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords) bool anyService = mServices > 0; + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + if (mServices & Service_Trade) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sBarter")->getString()); + mTopicsList->addItem(gmst.find("sBarter")->getString()); if (mServices & Service_BuySpells) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpells")->getString()); + mTopicsList->addItem(gmst.find("sSpells")->getString()); if (mServices & Service_Travel) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sTravel")->getString()); + mTopicsList->addItem(gmst.find("sTravel")->getString()); if (mServices & Service_CreateSpells) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sSpellmakingMenuTitle")->getString()); + mTopicsList->addItem(gmst.find("sSpellmakingMenuTitle")->getString()); // if (mServices & Service_Enchant) -// mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sEnchanting")->getString()); +// mTopicsList->addItem(gmst.find("sEnchanting")->getString()); if (mServices & Service_Training) - mTopicsList->addItem(MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sServiceTrainingTitle")->getString()); + mTopicsList->addItem(gmst.find("sServiceTrainingTitle")->getString()); if (anyService) mTopicsList->addSeparator(); @@ -301,7 +307,7 @@ void DialogueWindow::updateOptions() void DialogueWindow::goodbye() { - mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGoodbye")->getString()); + mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString()); mTopicsList->setEnabled(false); mEnabled = false; } diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 72feb84a4b..cb8efe5cc9 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -224,20 +224,20 @@ void RaceDialog::updateRaces() { mRaceList->removeAllItems(); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::Store<ESM::Race> &races = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>(); - MWWorld::RecListT<ESM::Race>::MapType::const_iterator it = store.races.list.begin(); - MWWorld::RecListT<ESM::Race>::MapType::const_iterator end = store.races.list.end(); + int index = 0; - for (; it != end; ++it) + MWWorld::Store<ESM::Race>::iterator it = races.begin() + for (; it != races.end(); ++it) { - const ESM::Race &race = it->second; - bool playable = race.mData.mFlags & ESM::Race::Playable; + bool playable = it->mData.mFlags & ESM::Race::Playable; if (!playable) // Only display playable races continue; - mRaceList->addItem(race.mName, it->first); - if (boost::iequals(it->first, mCurrentRaceId)) + mRaceList->addItem(it->mName, it->mId); + if (boost::iequals(it->mId, mCurrentRaceId)) mRaceList->setIndexSelected(index); ++index; } @@ -259,7 +259,7 @@ void RaceDialog::updateSkills() MyGUI::IntCoord coord1(0, 0, mSkillList->getWidth(), 18); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(mCurrentRaceId); + const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId); int count = sizeof(race->mData.mBonus)/sizeof(race->mData.mBonus[0]); // TODO: Find a portable macro for this ARRAYSIZE? for (int i = 0; i < count; ++i) { @@ -297,7 +297,7 @@ void RaceDialog::updateSpellPowers() MyGUI::IntCoord coord(0, 0, mSpellPowerList->getWidth(), 18); const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(mCurrentRaceId); + const ESM::Race *race = store.get<ESM::Race>().find(mCurrentRaceId); std::vector<std::string>::const_iterator it = race->mPowers.mList.begin(); std::vector<std::string>::const_iterator end = race->mPowers.mList.end(); diff --git a/apps/openmw/mwgui/review.cpp b/apps/openmw/mwgui/review.cpp index 961856b7ca..45adb53832 100644 --- a/apps/openmw/mwgui/review.cpp +++ b/apps/openmw/mwgui/review.cpp @@ -108,7 +108,9 @@ void ReviewDialog::setPlayerName(const std::string &name) void ReviewDialog::setRace(const std::string &raceId) { mRaceId = raceId; - const ESM::Race *race = MWBase::Environment::get().getWorld()->getStore().races.search(mRaceId); + + const ESM::Race *race = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().search(mRaceId); if (race) { ToolTips::createRaceToolTip(mRaceWidget, race); @@ -126,7 +128,9 @@ void ReviewDialog::setClass(const ESM::Class& class_) void ReviewDialog::setBirthSign(const std::string& signId) { mBirthSignId = signId; - const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.search(mBirthSignId); + + const ESM::BirthSign *sign = + MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().search(mBirthSignId); if (sign) { mBirthSignWidget->setCaption(sign->mName); diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index ece19cdc38..813a21b122 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -49,8 +49,12 @@ namespace MWGui void SpellBuyingWindow::addSpell(const std::string& spellId) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - int price = spell->mData.mCost*MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fSpellValueMult")->getFloat(); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Spell* spell = store.get<ESM::Spell>().find(spellId); + + int price = spell->mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->getFloat(); MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>( @@ -97,7 +101,8 @@ namespace MWGui for (MWMechanics::Spells::TIterator iter = merchantSpells.begin(); iter!=merchantSpells.end(); ++iter) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); if (spell->mData.mType!=ESM::Spell::ST_Spell) continue; // don't try to sell diseases, curses or powers diff --git a/apps/openmw/mwgui/widgets.cpp b/apps/openmw/mwgui/widgets.cpp index 5050ba88ad..82e1128263 100644 --- a/apps/openmw/mwgui/widgets.cpp +++ b/apps/openmw/mwgui/widgets.cpp @@ -228,8 +228,10 @@ void MWSpell::setSpellId(const std::string &spellId) void MWSpell::createEffectWidgets(std::vector<MyGUI::WidgetPtr> &effects, MyGUI::WidgetPtr creator, MyGUI::IntCoord &coord, int flags) { - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Spell *spell = store.spells.search(mId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Spell *spell = store.get<ESM::Spell>().search(mId); MYGUI_ASSERT(spell, "spell with id '" << mId << "' not found"); MWSpellEffectPtr effect = nullptr; @@ -259,8 +261,10 @@ void MWSpell::updateWidgets() { if (mSpellNameWidget && mWindowManager) { - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Spell *spell = store.spells.search(mId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Spell *spell = store.get<ESM::Spell>().search(mId); if (spell) static_cast<MyGUI::TextBox*>(mSpellNameWidget)->setCaption(spell->mName); else @@ -389,8 +393,11 @@ void MWSpellEffect::updateWidgets() if (!mWindowManager) return; - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::MagicEffect *magicEffect = store.magicEffects.search(mEffectParams.mEffectID); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::MagicEffect *magicEffect = + store.get<ESM::MagicEffect>().search(mEffectParams.mEffectID); assert(magicEffect); assert(mWindowManager); diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 525341a309..6073bc6d94 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -68,6 +68,17 @@ namespace MWWorld std::map<int, StoreBase *> mStores; public: + /// \todo replace with SharedIterator<StoreBase> + typedef std::map<int, StoreBase *>::const_iterator iterator; + + iterator begin() const { + return mStores.begin(); + } + + iterator end() const { + return mStores.end(); + } + // Look up the given ID in 'all'. Returns 0 if not found. int find(const std::string &id) const { From 5c1b3fc043e17a4f3912392576dba1b1bec8a09b Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Mon, 5 Nov 2012 20:45:04 +0000 Subject: [PATCH 137/255] Fixed: scene: adjust rotation/scale when creating objects --- apps/openmw/mwrender/renderingmanager.cpp | 2 +- apps/openmw/mwworld/scene.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 2daf990876..1b9f46781a 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -237,8 +237,8 @@ void RenderingManager::addObject (const MWWorld::Ptr& ptr){ const MWWorld::Class& class_ = MWWorld::Class::get (ptr); class_.insertObjectRendering(ptr, *this); - } + void RenderingManager::removeObject (const MWWorld::Ptr& ptr) { if (!mObjects.deleteObject (ptr)) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 37cc23f5ff..881b090fa5 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -41,6 +41,8 @@ namespace { rendering.addObject(ptr); class_.insertObject(ptr, physics); + MWBase::Environment::get().getWorld()->rotateObject(ptr, 0, 0, 0, true); + MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().mScale); } catch (const std::exception& e) { @@ -417,6 +419,8 @@ namespace MWWorld { mRendering.addObject(ptr); MWWorld::Class::get(ptr).insertObject(ptr, *mPhysics); + MWBase::Environment::get().getWorld()->rotateObject(ptr, 0, 0, 0, true); + MWBase::Environment::get().getWorld()->scaleObject(ptr, ptr.getCellRef().mScale); } void Scene::removeObjectFromScene (const Ptr& ptr) From 3e5b396b56853b80418b78bf98cf4d5ba9b9914d Mon Sep 17 00:00:00 2001 From: emoose <LeonDavidSaunders@gmail.com> Date: Mon, 5 Nov 2012 21:10:04 +0000 Subject: [PATCH 138/255] Changed: world: cleanup --- apps/openmw/mwworld/worldimp.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 58d2a9eac3..2e6d4efd9e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -189,11 +189,8 @@ namespace MWWorld mPlayer = new MWWorld::Player (mStore.npcs.find ("player"), *this); mRendering->attachCameraTo(mPlayer->getPlayer()); - std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player - //We will need to support the 1st person file too in the future mPhysics->addActor(mPlayer->getPlayer()); -// mPhysics->addActor (mPlayer->getPlayer().getRefData().getHandle(), playerCollisionFile, Ogre::Vector3 (0, 0, 0), 1, Ogre::Quaternion::ZERO); - + // global variables mGlobalVariables = new Globals (mStore); From 2841d831a63875824ef055c65e7bc43433ba50bd Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Mon, 5 Nov 2012 23:16:37 +0100 Subject: [PATCH 139/255] Disposition is now updated everyframe --- apps/openmw/mwgui/dialogue.cpp | 13 ++++++++++++- apps/openmw/mwgui/dialogue.hpp | 1 + apps/openmw/mwgui/windowmanagerimp.cpp | 2 ++ apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 1 - 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 9725df7fe6..f3cc66f380 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -51,7 +51,7 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_dialogue_window.layout", parWindowManager) - , mEnabled(true) + , mEnabled(false) , mServices(0) { // Centre dialog @@ -311,3 +311,14 @@ void DialogueWindow::onReferenceUnavailable() { mWindowManager.removeGuiMode(GM_Dialogue); } + +void DialogueWindow::onFrame() +{ + if(mEnabled) + { + mDispositionBar->setProgressRange(100); + mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); + mDispositionText->eraseText(0, mDispositionText->getTextLength()); + mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154"); + } +} diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 3a89409cac..bb9acf5db9 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -47,6 +47,7 @@ namespace MWGui void addTitle(std::string text); void askQuestion(std::string question); void goodbye(); + void onFrame(); // make sure to call these before setKeywords() void setServices(int services) { mServices = services; } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 0350581e45..bf95c6ae77 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -582,6 +582,8 @@ void WindowManager::onFrame (float frameDuration) mDragAndDrop->mDraggedWidget->setPosition(MyGUI::InputManager::getInstance().getMousePosition()); } + mDialogueWindow->onFrame(); + mInventoryWindow->onFrame(); mStatsWindow->onFrame(); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 7f4ab600f2..3f76f48a68 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -366,7 +366,6 @@ namespace MWMechanics } else if (npcFaction != "") { - std::cout << "npc has a faction!"; for(std::vector<ESM::Faction::Reaction>::const_iterator it = store.factions.find(toLower(npcFaction))->mReactions.begin();it != store.factions.find(toLower(npcFaction))->mReactions.end();it++) { if(playerSkill.getFactionRanks().find(toLower(it->mFaction)) != playerSkill.getFactionRanks().end() ) From a9c1ce412a1caf7613ca922f888cb705928b296a Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 11:29:18 +0400 Subject: [PATCH 140/255] applying new interface vol.7, inconsistent --- apps/openmw/mwgui/quickkeysmenu.cpp | 30 ++++++++++++----- apps/openmw/mwgui/spellwindow.cpp | 28 +++++++++++----- apps/openmw/mwgui/stats_window.cpp | 18 +++++++---- apps/openmw/mwgui/tooltips.cpp | 45 ++++++++++++++++++-------- apps/openmw/mwgui/tradewindow.cpp | 6 +++- apps/openmw/mwgui/trainingwindow.cpp | 10 ++++-- apps/openmw/mwgui/travelwindow.cpp | 9 ++++-- apps/openmw/mwgui/windowmanagerimp.cpp | 16 ++++++--- 8 files changed, 115 insertions(+), 47 deletions(-) diff --git a/apps/openmw/mwgui/quickkeysmenu.cpp b/apps/openmw/mwgui/quickkeysmenu.cpp index e927af95d3..02512425de 100644 --- a/apps/openmw/mwgui/quickkeysmenu.cpp +++ b/apps/openmw/mwgui/quickkeysmenu.cpp @@ -29,8 +29,11 @@ namespace bool sortSpells(const std::string& left, const std::string& right) { - const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); - const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); + const MWWorld::Store<ESM::Spell> &spells = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>(); + + const ESM::Spell* a = spells.find(left); + const ESM::Spell* b = spells.find(right); int cmp = a->mName.compare(b->mName); return cmp < 0; @@ -234,9 +237,15 @@ namespace MWGui MyGUI::ImageBox* image = frame->createWidget<MyGUI::ImageBox>("ImageBox", MyGUI::IntCoord(5, 5, 32, 32), MyGUI::Align::Default); + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + // use the icon of the first effect - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld()->getStore().magicEffects.find(spell->mEffects.mList.front().mEffectID); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(spellId); + + const ESM::MagicEffect* effect = + esmStore.get<ESM::MagicEffect>().find(spell->mEffects.mList.front().mEffectID); + std::string path = effect->mIcon; int slashPos = path.find("\\"); path.insert(slashPos+1, "b_"); @@ -434,11 +443,14 @@ namespace MWGui spellList.push_back(*it); } + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + std::vector<std::string> powers; std::vector<std::string>::iterator it = spellList.begin(); while (it != spellList.end()) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); if (spell->mData.mType == ESM::Spell::ST_Power) { powers.push_back(*it); @@ -465,7 +477,9 @@ namespace MWGui if (enchantId != "") { // only add items with "Cast once" or "Cast on use" - const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); + const ESM::Enchantment* enchant = + esmStore.get<ESM::Enchantment>().find(enchantId); + int type = enchant->mData.mType; if (type != ESM::Enchantment::CastOnce && type != ESM::Enchantment::WhenUsed) @@ -487,7 +501,7 @@ namespace MWGui for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); @@ -504,7 +518,7 @@ namespace MWGui addGroup("#{sSpells}", ""); for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); MyGUI::Button* t = mMagicList->createWidget<MyGUI::Button>("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); diff --git a/apps/openmw/mwgui/spellwindow.cpp b/apps/openmw/mwgui/spellwindow.cpp index c7f61a935b..d62b23de47 100644 --- a/apps/openmw/mwgui/spellwindow.cpp +++ b/apps/openmw/mwgui/spellwindow.cpp @@ -26,8 +26,11 @@ namespace { bool sortSpells(const std::string& left, const std::string& right) { - const ESM::Spell* a = MWBase::Environment::get().getWorld()->getStore().spells.find(left); - const ESM::Spell* b = MWBase::Environment::get().getWorld()->getStore().spells.find(right); + const MWWorld::Store<ESM::Spell> &spells = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>(); + + const ESM::Spell* a = spells.find(left); + const ESM::Spell* b = spells.find(right); int cmp = a->mName.compare(b->mName); return cmp < 0; @@ -139,11 +142,15 @@ namespace MWGui spellList.push_back(*it); } + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + std::vector<std::string> powers; std::vector<std::string>::iterator it = spellList.begin(); while (it != spellList.end()) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); + if (spell->mData.mType == ESM::Spell::ST_Power) { powers.push_back(*it); @@ -170,7 +177,9 @@ namespace MWGui if (enchantId != "") { // only add items with "Cast once" or "Cast on use" - const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(enchantId); + const ESM::Enchantment* enchant = + esmStore.get<ESM::Enchantment>().find(enchantId); + int type = enchant->mData.mType; if (type != ESM::Enchantment::CastOnce && type != ESM::Enchantment::WhenUsed) @@ -191,7 +200,7 @@ namespace MWGui for (std::vector<std::string>::const_iterator it = powers.begin(); it != powers.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); @@ -211,7 +220,7 @@ namespace MWGui addGroup("#{sSpells}", "#{sCostChance}"); for (std::vector<std::string>::const_iterator it = spellList.begin(); it != spellList.end(); ++it) { - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(*it); + const ESM::Spell* spell = esmStore.get<ESM::Spell>().find(*it); MyGUI::Button* t = mSpellView->createWidget<MyGUI::Button>("SpellText", MyGUI::IntCoord(4, mHeight, mWidth-8, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top); t->setCaption(spell->mName); @@ -244,7 +253,8 @@ namespace MWGui { MWWorld::Ptr item = *it; - const ESM::Enchantment* enchant = MWBase::Environment::get().getWorld()->getStore().enchants.find(MWWorld::Class::get(item).getEnchantment(item)); + const ESM::Enchantment* enchant = + esmStore.get<ESM::Enchantment>().find(MWWorld::Class::get(item).getEnchantment(item)); // check if the item is currently equipped (will display in a different color) bool equipped = false; @@ -378,7 +388,9 @@ namespace MWGui if (MyGUI::InputManager::getInstance().isShiftPressed()) { // delete spell, if allowed - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); + if (spell->mData.mFlags & ESM::Spell::F_Always || spell->mData.mType == ESM::Spell::ST_Power) { diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index ccba9cf747..5d30b142a0 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -57,7 +57,7 @@ StatsWindow::StatsWindow (MWBase::WindowManager& parWindowManager) const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); for (int i=0; names[i][0]; ++i) { - setText (names[i][0], store.gameSettings.find (names[i][1])->getString()); + setText (names[i][0], store.get<ESM::GameSetting>().find (names[i][1])->getString()); } getWidget(mSkillView, "SkillView"); @@ -363,12 +363,16 @@ void StatsWindow::addSkills(const SkillList &skills, const std::string &titleId, float modified = stat.getModified(); int progressPercent = (modified - float(static_cast<int>(modified))) * 100; - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::Skill* skill = esmStore.get<ESM::Skill>().find(skillId); assert(skill); std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); + const ESM::Attribute* attr = + esmStore.get<ESM::Attribute>().find(skill->mData.mAttribute); assert(attr); std::string state = "normal"; @@ -425,7 +429,9 @@ void StatsWindow::updateSkillArea() const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); // race tooltip - const ESM::Race* playerRace = store.races.find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); + const ESM::Race* playerRace = + store.get<ESM::Race>().find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); + MyGUI::Widget* raceWidget; getWidget(raceWidget, "RaceText"); ToolTips::createRaceToolTip(raceWidget, playerRace); @@ -464,8 +470,8 @@ void StatsWindow::updateSkillArea() text += std::string("\n\n#DDC79E#{sNextRank} ") + faction->mRanks[it->second+1]; ESM::RankData rankData = faction->mData.mRankData[it->second+1]; - const ESM::Attribute* attr1 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute1); - const ESM::Attribute* attr2 = MWBase::Environment::get().getWorld()->getStore().attributes.search(faction->mData.mAttribute2); + const ESM::Attribute* attr1 = store.get<ESM::Attribute>().find(faction->mData.mAttribute1); + const ESM::Attribute* attr2 = store.get<ESM::Attribute>().find(faction->mData.mAttribute2); assert(attr1 && attr2); text += "\n#BF9959#{" + attr1->mName + "}: " + boost::lexical_cast<std::string>(rankData.mAttribute1) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index d47a0f547f..93118fa110 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -179,7 +179,9 @@ void ToolTips::onFrame(float frameDuration) else if (type == "Spell") { ToolTipInfo info; - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find(focus->getUserString("Spell")); + + const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(focus->getUserString("Spell")); info.caption = spell->mName; Widgets::SpellEffectList effects; std::vector<ESM::ENAMstruct>::const_iterator end = spell->mEffects.mList.end(); @@ -368,7 +370,7 @@ IntSize ToolTips::createToolTip(const MWGui::ToolTipInfo& info) const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore(); if (info.enchant != "") { - enchant = store.enchants.search(info.enchant); + enchant = store.get<ESM::Enchantment>().find(info.enchant); if (enchant->mData.mType == ESM::Enchantment::CastOnce) text += "\n#{sItemCastOnce}"; else if (enchant->mData.mType == ESM::Enchantment::WhenStrikes) @@ -571,10 +573,15 @@ void ToolTips::createSkillToolTip(MyGUI::Widget* widget, int skillId) if (skillId == -1) return; + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + const std::string &skillNameId = ESM::Skill::sSkillNameIds[skillId]; - const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().skills.search(skillId); + const ESM::Skill* skill = store.get<ESM::Skill>().find(skillId); assert(skill); - const ESM::Attribute* attr = MWBase::Environment::get().getWorld()->getStore().attributes.search(skill->mData.mAttribute); + + const ESM::Attribute* attr = + store.get<ESM::Attribute>().find(skill->mData.mAttribute); assert(attr); std::string icon = "icons\\k\\" + ESM::Skill::sIconNames[skillId]; @@ -607,12 +614,14 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str widget->setUserString("Caption_CenteredCaption", name); std::string specText; // get all skills of this specialisation - std::map<int, ESM::Skill> skills = MWBase::Environment::get().getWorld()->getStore().skills.list; - for (std::map<int, ESM::Skill>::const_iterator it = skills.begin(); - it != skills.end(); ++it) + const MWWorld::Store<ESM::Skill> &skills = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>(); + + MWWorld::Store<ESM::Skill>::iterator it = skills.begin(); + for (; it != skills.end(); ++it) { - if (it->second.mData.mSpecialization == specId) - specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->second.mIndex] + "}"; + if (it->mData.mSpecialization == specId) + specText += std::string("\n#{") + ESM::Skill::sSkillNameIds[it->mIndex] + "}"; } widget->setUserString("Caption_CenteredCaptionText", specText); widget->setUserString("ToolTipLayout", "TextWithCenteredCaptionToolTip"); @@ -621,7 +630,10 @@ void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::str void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& birthsignId) { - const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getStore().birthSigns.find(birthsignId); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + + const ESM::BirthSign *sign = store.get<ESM::BirthSign>().find(birthsignId); widget->setUserString("ToolTipType", "Layout"); widget->setUserString("ToolTipLayout", "BirthSignToolTip"); @@ -640,7 +652,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& for (; it != end; ++it) { const std::string &spellId = *it; - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); + const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId); if (!spell) continue; // Skip spells which cannot be found ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType); @@ -655,7 +667,11 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& spells.push_back(spellId); } - struct{ const std::vector<std::string> &spells; std::string label; } categories[3] = { + struct { + const std::vector<std::string> &spells; + std::string label; + } + categories[3] = { {abilities, "sBirthsignmenu1"}, {powers, "sPowers"}, {spells, "sBirthsignmenu2"} @@ -672,7 +688,7 @@ void ToolTips::createBirthsignToolTip(MyGUI::Widget* widget, const std::string& const std::string &spellId = *it; - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.search(spellId); + const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId); text += "\n#BF9959" + spell->mName; } } @@ -711,7 +727,8 @@ void ToolTips::createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playe void ToolTips::createMagicEffectToolTip(MyGUI::Widget* widget, short id) { - const ESM::MagicEffect* effect = MWBase::Environment::get().getWorld ()->getStore ().magicEffects.find(id); + const ESM::MagicEffect* effect = + MWBase::Environment::get().getWorld ()->getStore ().get<ESM::MagicEffect>().find(id); const std::string &name = ESM::MagicEffect::effectIdToString (id); std::string icon = effect->mIcon; diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 0e755f49d7..6498cd7120 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -107,10 +107,14 @@ namespace MWGui bool goldFound = false; MWWorld::Ptr gold; MWWorld::ContainerStore& playerStore = mWindowManager.getInventoryWindow()->getContainerStore(); + + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + for (MWWorld::ContainerStoreIterator it = playerStore.begin(); it != playerStore.end(); ++it) { - if (MWWorld::Class::get(*it).getName(*it) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (MWWorld::Class::get(*it).getName(*it) == gmst.find("sGold")->getString()) { goldFound = true; gold = *it; diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 226167ba30..08e64eba88 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -113,8 +113,11 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + /// \todo mercantile skill - int price = pcStats.getSkill (skillId).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); + int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt (); if (mWindowManager.getInventoryWindow()->getPlayerGold()<price) return; @@ -128,8 +131,9 @@ namespace MWGui // increase skill MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); - const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->mBase->mClass); + + const ESM::Class *class_ = + store.get<ESM::Class>().find(playerRef->mBase->mClass); pcStats.increaseSkill (skillId, *class_, true); // remove gold diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 6431aa76ea..0e7ebaaa3e 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -54,16 +54,19 @@ namespace MWGui { int price = 0; + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + if(interior) { - price = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fMagesGuildTravel")->getFloat(); + price = gmst.find("fMagesGuildTravel")->getFloat(); } else { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); - price = d/MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelMult")->getFloat(); + price = d/gmst.find("fTravelMult")->getFloat(); } MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); @@ -142,7 +145,7 @@ namespace MWGui cell = MWBase::Environment::get().getWorld()->getExterior(x,y); ESM::Position PlayerPos = player.getRefData().getPosition(); float d = sqrt( pow(pos.pos[0] - PlayerPos.pos[0],2) + pow(pos.pos[1] - PlayerPos.pos[1],2) + pow(pos.pos[2] - PlayerPos.pos[2],2) ); - int time = int(d /MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fTravelTimeMult")->getFloat()); + int time = int(d /MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fTravelTimeMult")->getFloat()); for(int i = 0;i < time;i++) { MWBase::Environment::get().getMechanicsManager ()->restoreDynamicStats (); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index d5d88960a9..8e4187f7f2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -554,7 +554,9 @@ int WindowManager::readPressedButton () std::string WindowManager::getGameSettingString(const std::string &id, const std::string &default_) { - const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.search(id); + const ESM::GameSetting *setting = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().search(id); + if (setting && setting->mType == ESM::VT_String) return setting->getString(); return default_; @@ -614,7 +616,8 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) } else { - const ESM::Region* region = MWBase::Environment::get().getWorld()->getStore().regions.search(cell->mCell->mRegion); + const ESM::Region* region = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search(cell->mCell->mRegion); if (region) name = region->mName; else @@ -717,7 +720,9 @@ void WindowManager::setDragDrop(bool dragDrop) void WindowManager::onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result) { - const ESM::GameSetting *setting = MWBase::Environment::get().getWorld()->getStore().gameSettings.find(_tag); + const ESM::GameSetting *setting = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(_tag); + if (setting && setting->mType == ESM::VT_String) _result = setting->getString(); else @@ -808,7 +813,10 @@ void WindowManager::removeGuiMode(GuiMode mode) void WindowManager::setSelectedSpell(const std::string& spellId, int successChancePercent) { mHud->setSelectedSpell(spellId, successChancePercent); - const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().spells.find(spellId); + + const ESM::Spell* spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); + mSpellWindow->setTitle(spell->mName); } From 932a9dc6f900e5547fc0577b4fb2daff533c8d86 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 11:53:00 +0400 Subject: [PATCH 141/255] applying new interface vol.8, inconsistent --- apps/openmw/mwrender/debugging.cpp | 3 ++- apps/openmw/mwrender/globalmap.cpp | 25 +++++++++++++---------- apps/openmw/mwrender/npcanimation.cpp | 18 +++++++++------- apps/openmw/mwrender/renderingmanager.cpp | 10 ++++++--- apps/openmw/mwrender/terrain.cpp | 13 ++++++++---- 5 files changed, 43 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index c980bef00c..1548cc1b0f 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -228,7 +228,8 @@ void Debugging::togglePathgrid() void Debugging::enableCellPathgrid(MWWorld::Ptr::CellStore *store) { - ESM::Pathgrid *pathgrid = MWBase::Environment::get().getWorld()->getStore().pathgrids.search(*store->mCell); + const ESM::Pathgrid *pathgrid = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*store->mCell); if (!pathgrid) return; Vector3 cellPathGridPos(0, 0, 0); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index e8ddecb3d2..d1e3602b79 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -28,18 +28,21 @@ namespace MWRender { Ogre::TexturePtr tex; + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + // get the size of the world - const MWWorld::CellList::ExtCells& extCells = MWBase::Environment::get().getWorld ()->getStore ().cells.extCells; - for (MWWorld::CellList::ExtCells::const_iterator it = extCells.begin(); it != extCells.end(); ++it) + MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin(); + for (; it != esmStore.get<ESM::Cell>().end(); ++it) { - if (it->first.first < mMinX) - mMinX = it->first.first; - if (it->first.first > mMaxX) - mMaxX = it->first.first; - if (it->first.second < mMinY) - mMinY = it->first.second; - if (it->first.second > mMaxY) - mMaxY = it->first.second; + if (it->getGridX() < mMinX) + mMinX = it->getGridX(); + if (it->getGridX() > mMaxX) + mMaxX = it->getGridX(); + if (it->getGridY() < mMinY) + mMinY = it->getGridY(); + if (it->getGridY() > mMaxY) + mMaxY = it->getGridY(); } int cellSize = 24; @@ -58,7 +61,7 @@ namespace MWRender { for (int y = mMinY; y <= mMaxY; ++y) { - ESM::Land* land = MWBase::Environment::get().getWorld ()->getStore ().lands.search (x,y); + ESM::Land* land = esmStore.get<ESM::Land>().search (x,y); if (land) { diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 2e2d0b9da8..2153b1407f 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -62,13 +62,14 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor mPartPriorities[init] = 0; } - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.races.find(ref->mBase->mRace); + const MWWorld::ESMStore &store = + MWBase::Environment::get().getWorld()->getStore(); + const ESM::Race *race = store.get<ESM::Race>().find(ref->mBase->mRace); std::string hairID = ref->mBase->mHair; std::string headID = ref->mBase->mHead; - headModel = "meshes\\" + store.bodyParts.find(headID)->mModel; - hairModel = "meshes\\" + store.bodyParts.find(hairID)->mModel; + headModel = "meshes\\" + store.get<ESM::BodyPart>().find(headID)->mModel; + hairModel = "meshes\\" + store.get<ESM::BodyPart>().find(hairID)->mModel; npcName = ref->mBase->mName; isFemale = !!(ref->mBase->mFlags&ESM::NPC::Female); @@ -331,7 +332,7 @@ void NpcAnimation::updateParts() bool tryfemale = isFemale; int ni = 0; do { - part = store.bodyParts.search(bodyRaceID+(tryfemale?"_f_":"_m_")+PartTypeList[i].name[ni]); + part = store.get<ESM::BodyPart>().search(bodyRaceID+(tryfemale?"_f_":"_m_")+PartTypeList[i].name[ni]); if(part) break; ni ^= 1; @@ -569,11 +570,14 @@ void NpcAnimation::addPartGroup(int group, int priority, std::vector<ESM::PartRe { ESM::PartReference &part = parts[i]; + const MWWorld::Store<ESM::BodyPart> &parts = + MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); + const ESM::BodyPart *bodypart = 0; if(isFemale) - bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.mFemale); + bodypart = parts.search(part.mFemale); if(!bodypart) - bodypart = MWBase::Environment::get().getWorld()->getStore().bodyParts.search(part.mMale); + bodypart = parts.search(part.mMale); if(bodypart) addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index d04ffbab95..0f649886c3 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -373,10 +373,14 @@ void RenderingManager::update (float duration) } } -void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store){ - if(store->mCell->mData.mFlags & store->mCell->HasWater +void RenderingManager::waterAdded (MWWorld::Ptr::CellStore *store) +{ + const MWWorld::Store<ESM::Land> &lands = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>(); + + if(store->mCell->mData.mFlags & ESM::Cell::HasWater || ((store->mCell->isExterior()) - && !MWBase::Environment::get().getWorld()->getStore().lands.search(store->mCell->getGridX(),store->mCell->getGridY()) )) // always use water, if the cell does not have land. + && !lands.search(store->mCell->getGridX(),store->mCell->getGridY()) )) // always use water, if the cell does not have land. { if(mWater == 0) mWater = new MWRender::Water(mRendering.getCamera(), this, store->mCell); diff --git a/apps/openmw/mwrender/terrain.cpp b/apps/openmw/mwrender/terrain.cpp index da38bf20b4..e5a1362d7b 100644 --- a/apps/openmw/mwrender/terrain.cpp +++ b/apps/openmw/mwrender/terrain.cpp @@ -95,7 +95,8 @@ namespace MWRender const int cellX = store->mCell->getGridX(); const int cellY = store->mCell->getGridY(); - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); + ESM::Land* land = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(cellX, cellY); if (land == NULL) // no land data means we're not going to create any terrain. return; @@ -245,7 +246,10 @@ namespace MWRender { //NB: All vtex ids are +1 compared to the ltex ids - assert( (int)MWBase::Environment::get().getWorld()->getStore().landTexts.getSize() >= (int)ltexIndex - 1 && + const MWWorld::Store<ESM::LandTexture> <exStore = + MWBase::Environment::get().getWorld()->getStore().get<ESM::LandTexture>(); + + assert( (int)ltexStore.getSize() >= (int)ltexIndex - 1 && "LAND.VTEX must be within the bounds of the LTEX array"); std::string texture; @@ -255,7 +259,7 @@ namespace MWRender } else { - texture = MWBase::Environment::get().getWorld()->getStore().landTexts.search(ltexIndex-1)->mTexture; + texture = ltexStore.search(ltexIndex-1)->mTexture; //TODO this is needed due to MWs messed up texture handling texture = texture.substr(0, texture.rfind(".")) + ".dds"; } @@ -411,7 +415,8 @@ namespace MWRender } - ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().lands.search(cellX, cellY); + ESM::Land* land = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(cellX, cellY); if ( land != NULL ) { if (!land->isDataLoaded(ESM::Land::DATA_VTEX)) From ff8da265ed30e9fe5a15a609ec7d134fa3fdc6cd Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 12:36:21 +0400 Subject: [PATCH 142/255] applying new interface vol.9, inconsistent --- apps/openmw/mwscript/globalscripts.cpp | 2 +- apps/openmw/mwscript/scriptmanagerimp.cpp | 15 ++++++------- apps/openmw/mwworld/actionread.cpp | 7 ++++-- apps/openmw/mwworld/cells.cpp | 17 +++++++------- apps/openmw/mwworld/containerstore.cpp | 7 ++++-- apps/openmw/mwworld/inventorystore.cpp | 2 +- apps/openmw/mwworld/localscripts.cpp | 2 +- apps/openmw/mwworld/player.cpp | 2 +- apps/openmw/mwworld/scene.cpp | 4 ++-- apps/openmw/mwworld/store.hpp | 4 ++-- apps/openmw/mwworld/weather.cpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 27 ++++++++++------------- 12 files changed, 48 insertions(+), 44 deletions(-) diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index 5cd769da77..b8287e7a3b 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -26,7 +26,7 @@ namespace MWScript void GlobalScripts::addScript (const std::string& name) { if (mScripts.find (name)==mScripts.end()) - if (const ESM::Script *script = mStore.scripts.find (name)) + if (const ESM::Script *script = mStore.get<ESM::Script>().find (name)) { Locals locals; diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 1f4e80382a..5d29e6e016 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -31,7 +31,7 @@ namespace MWScript bool Success = true; - if (const ESM::Script *script = mStore.scripts.find (name)) + if (const ESM::Script *script = mStore.get<ESM::Script>().find (name)) { if (mVerbose) std::cout << "compiling script: " << name << std::endl; @@ -125,15 +125,14 @@ namespace MWScript std::pair<int, int> ScriptManager::compileAll() { - typedef MWWorld::ScriptListT<ESM::Script>::MapType Container; - - const Container& scripts = mStore.scripts.list; - int count = 0; int success = 0; - for (Container::const_iterator iter (scripts.begin()); iter!=scripts.end(); ++iter, ++count) - if (compile (iter->first)) + const MWWorld::Store<ESM::Script>& scripts = mStore.get<ESM::Script>(); + MWWorld::Store<ESM::Script>::iterator it = scripts.begin(); + + for (; it != scripts.end(); ++iter, ++count) + if (compile (it->mId)) ++success; return std::make_pair (count, success); @@ -170,7 +169,7 @@ namespace MWScript int ScriptManager::getLocalIndex (const std::string& scriptId, const std::string& variable, char type) { - const ESM::Script *script = mStore.scripts.find (scriptId); + const ESM::Script *script = mStore.get<ESM::Script>().find (scriptId); int offset = 0; int size = 0; diff --git a/apps/openmw/mwworld/actionread.cpp b/apps/openmw/mwworld/actionread.cpp index 66539e75b4..6d5d9d8fde 100644 --- a/apps/openmw/mwworld/actionread.cpp +++ b/apps/openmw/mwworld/actionread.cpp @@ -42,8 +42,11 @@ namespace MWWorld && !npcStats.hasBeenUsed (ref->mBase->mId)) { MWWorld::LiveCellRef<ESM::NPC> *playerRef = player.get<ESM::NPC>(); - const ESM::Class *class_ = MWBase::Environment::get().getWorld()->getStore().classes.find ( - playerRef->mBase->mClass); + + const ESM::Class *class_ = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find ( + playerRef->mBase->mClass + ); npcStats.increaseSkill (ref->mBase->mData.mSkillID, *class_, true); diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index f046f1723b..beed6f1d76 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -97,7 +97,7 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) if (result==mExteriors.end()) { - const ESM::Cell *cell = mStore.cells.searchExt (x, y); + const ESM::Cell *cell = mStore.get<ESM::Cell>().search(x, y); if (!cell) { @@ -132,7 +132,7 @@ MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name) if (result==mInteriors.end()) { - const ESM::Cell *cell = mStore.cells.findInt (name); + const ESM::Cell *cell = mStore.get<ESM::Cell>().find(name); result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first; } @@ -264,10 +264,12 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) } // Now try the other cells - for (MWWorld::CellList::IntCells::const_iterator iter = mStore.cells.intCells.begin(); - iter!=mStore.cells.intCells.end(); ++iter) + const MWWorld::Store<ESM::Cell> &cells = mStore.get<ESM::Cell>(); + MWWorld::Store<ESM::Cell>::iterator iter; + + for (iter = cells.intBegin(); iter != cells.intEnd(); ++iter) { - Ptr::CellStore *cellStore = getCellStore (iter->second); + Ptr::CellStore *cellStore = getCellStore (*iter); Ptr ptr = getPtrAndCache (name, *cellStore); @@ -275,10 +277,9 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) return ptr; } - for (MWWorld::CellList::ExtCells::const_iterator iter = mStore.cells.extCells.begin(); - iter!=mStore.cells.extCells.end(); ++iter) + for (iter = cells.extBegin(); iter != cells.extEnd(); ++it) { - Ptr::CellStore *cellStore = getCellStore (iter->second); + Ptr::CellStore *cellStore = getCellStore (*iter); Ptr ptr = getPtrAndCache (name, *cellStore); diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index b8297b1f06..e47f2191af 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -74,9 +74,12 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) { int type = getType(ptr); + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); + // gold needs special handling: when it is inserted into a container, the base object automatically becomes Gold_001 // this ensures that gold piles of different sizes stack with each other (also, several scripts rely on Gold_001 for detecting player gold) - if (MWWorld::Class::get(ptr).getName(ptr) == MWBase::Environment::get().getWorld()->getStore().gameSettings.find("sGold")->getString()) + if (MWWorld::Class::get(ptr).getName(ptr) == esmStore.get<ESM::GameSetting>().find("sGold")->getString()) { MWWorld::LiveCellRef<ESM::Miscellaneous> *gold = ptr.get<ESM::Miscellaneous>(); @@ -87,7 +90,7 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& ptr) || compare_string_ci(gold->mRef.mRefID, "gold_025") || compare_string_ci(gold->mRef.mRefID, "gold_100")) { - MWWorld::ManualRef ref(MWBase::Environment::get().getWorld()->getStore(), "Gold_001"); + MWWorld::ManualRef ref(esmStore, "Gold_001"); int count = (ptr.getRefData().getCount() == 1) ? gold->mBase->mData.mValue : ptr.getRefData().getCount(); ref.getPtr().getRefData().setCount(count); diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index a69d658b36..dd518ff6a4 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -230,7 +230,7 @@ const MWMechanics::MagicEffects& MWWorld::InventoryStore::getMagicEffects() if (!enchantmentId.empty()) { const ESM::Enchantment& enchantment = - *MWBase::Environment::get().getWorld()->getStore().enchants.find (enchantmentId); + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find (enchantmentId); if (enchantment.mData.mType==ESM::Enchantment::ConstantEffect) mMagicEffects.add (enchantment.mEffects); diff --git a/apps/openmw/mwworld/localscripts.cpp b/apps/openmw/mwworld/localscripts.cpp index c196298b2f..a821ad4868 100644 --- a/apps/openmw/mwworld/localscripts.cpp +++ b/apps/openmw/mwworld/localscripts.cpp @@ -61,7 +61,7 @@ std::pair<std::string, MWWorld::Ptr> MWWorld::LocalScripts::getNext() void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr) { - if (const ESM::Script *script = mStore.scripts.find (scriptName)) + if (const ESM::Script *script = mStore.get<ESM::Script>().find (scriptName)) { ptr.getRefData().setLocals (*script); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 1b322b49f0..a1318f7272 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -27,7 +27,7 @@ namespace MWWorld playerPos[0] = playerPos[1] = playerPos[2] = 0; /// \todo Do not make a copy of classes defined in esm/p records. - mClass = new ESM::Class (*world.getStore().classes.find (player->mClass)); + mClass = new ESM::Class (*world.getStore().get<ESM::Class>().find (player->mClass)); } Player::~Player() diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 2b12ab940c..1700aa29f2 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -83,7 +83,7 @@ namespace MWWorld if ((*iter)->mCell->isExterior()) { ESM::Land* land = - MWBase::Environment::get().getWorld()->getStore().lands.search( + MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() ); @@ -118,7 +118,7 @@ namespace MWWorld if (cell->mCell->isExterior()) { ESM::Land* land = - MWBase::Environment::get().getWorld()->getStore().lands.search( + MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search( cell->mCell->getGridX(), cell->mCell->getGridY() ); diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index af1fae9a76..c4d70ba08e 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -490,7 +490,7 @@ namespace MWWorld } /// \todo implement appropriate index - const ESM::Cell *searchExteriorByName(const std::string &id) const { + const ESM::Cell *searchExtByName(const std::string &id) const { std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin(); for (; it != mSharedExt.end(); ++it) { if (StringUtils::ciEqual((*it)->mName, id)) { @@ -501,7 +501,7 @@ namespace MWWorld } /// \todo implement appropriate index - const ESM::Cell *searchExteriorByRegion(const std::string &id) const { + const ESM::Cell *searchExtByRegion(const std::string &id) const { std::vector<ESM::Cell *>::const_iterator it = mSharedExt.begin(); for (; it != mSharedExt.end(); ++it) { if (StringUtils::ciEqual((*it)->mRegion, id)) { diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 08e78a49cf..009b325c06 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -511,7 +511,8 @@ void WeatherManager::update(float duration) else { // get weather probabilities for the current region - const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.search (regionstr); + const ESM::Region *region = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Region>().search (regionstr); if (region != 0) { diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 7deccd09f5..02fac8b619 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -186,7 +186,7 @@ namespace MWWorld mEsm.open (masterPath.string()); mStore.load (mEsm); - mPlayer = new MWWorld::Player (mStore.npcs.find ("player"), *this); + mPlayer = new MWWorld::Player (mStore.get<ESM::NPC>().find ("player"), *this); mRendering->attachCameraTo(mPlayer->getPlayer()); std::string playerCollisionFile = "meshes\\base_anim.nif"; //This is used to make a collision shape for our player @@ -224,21 +224,19 @@ namespace MWWorld const ESM::Cell *World::getExterior (const std::string& cellName) const { // first try named cells - if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName)) + const ESM::Cell *cell = mStore.get<ESM::Cell>().searchExtByName (cellName); + if (cell != 0) { return cell; + } // didn't work -> now check for regions - std::string cellName2 = MWWorld::RecListT<ESM::Region>::toLower (cellName); - - for (MWWorld::RecListT<ESM::Region>::MapType::const_iterator iter (mStore.regions.list.begin()); - iter!=mStore.regions.list.end(); ++iter) + const MWWorld::Store<ESM::Region> ®ions = mStore.get<ESM::Region>(); + MWWorld::Store<ESM::Region>::iterator it = regions.begin(); + for (; it != regions.end(); ++it) { - if (MWWorld::RecListT<ESM::Region>::toLower (iter->second.mName)==cellName2) + if (MWWorld::StringUtils::ciEqual(cellName, it->mName)) { - if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first)) - return cell; - - break; + return mStore.get<ESM::Cell>().searchExtByRegion(it->mId); } } @@ -536,7 +534,7 @@ namespace MWWorld std::pair<std::string, float> result = mPhysics->getFacedHandle (*this); if (result.first.empty() || - result.second>getStore().gameSettings.find ("iMaxActivateDist")->getInt()) + result.second>getStore().get<ESM::GameSetting>().find ("iMaxActivateDist")->getInt()) return ""; return result.first; @@ -1103,13 +1101,12 @@ namespace MWWorld // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y); - const ESM::Cell* cell = mStore.cells.findExt(x,y); + const ESM::Cell* cell = mStore.get<ESM::Cell>().find(x,y); if (cell->mName != "") dest = cell->mName; else { - const ESM::Region* region = mStore.regions.search(cell->mRegion); - dest = region->mName; + dest = mStore.get<ESM::Region>().find(cell->mRegion)->mName; } } From e74b2c060de9153fcb6faedf37ef88e7fede9207 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 13:14:03 +0400 Subject: [PATCH 143/255] disable createRecord(), Land constness hack, various fixes with Store<T> interface --- apps/openmw/mwgui/birth.cpp | 2 +- apps/openmw/mwgui/class.cpp | 4 ++-- apps/openmw/mwgui/console.cpp | 2 +- apps/openmw/mwgui/race.cpp | 2 +- apps/openmw/mwgui/stats_window.cpp | 6 ++++-- apps/openmw/mwrender/globalmap.cpp | 2 +- apps/openmw/mwworld/store.hpp | 12 ++++++------ apps/openmw/mwworld/worldimp.cpp | 15 ++++++++------- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index 1891bf5500..4837821e0a 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -186,7 +186,7 @@ void BirthDialog::updateSpells() for (; it != end; ++it) { const std::string &spellId = *it; - const ESM::Spell *spell = store.spells.search(spellId); + const ESM::Spell *spell = store.get<ESM::Spell>().search(spellId); if (!spell) continue; // Skip spells which cannot be found ESM::Spell::SpellType type = static_cast<ESM::Spell::SpellType>(spell->mData.mType); diff --git a/apps/openmw/mwgui/class.cpp b/apps/openmw/mwgui/class.cpp index 461604b765..c14c7f74b5 100644 --- a/apps/openmw/mwgui/class.cpp +++ b/apps/openmw/mwgui/class.cpp @@ -188,8 +188,8 @@ void PickClassDialog::updateClasses() const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); int index = 0; - MWWorld::Store<ESM::Cell>::iterator it = store.get<ESM::Cell>().begin(); - for (; it != store.get<ESM::Cell>().end(); ++it) + MWWorld::Store<ESM::Class>::iterator it = store.get<ESM::Class>().begin(); + for (; it != store.get<ESM::Class>().end(); ++it) { bool playable = (it->mData.mIsPlayable != 0); if (!playable) // Only display playable classes diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 9595f32842..b2281d87e6 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -97,7 +97,7 @@ namespace MWGui for (MWWorld::ESMStore::iterator it = store.begin(); it != store.end(); ++it) { - iter->second->listIdentifier (mNames); + it->second->listIdentifier (mNames); } // sort diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index cb8efe5cc9..943081e65e 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -229,7 +229,7 @@ void RaceDialog::updateRaces() int index = 0; - MWWorld::Store<ESM::Race>::iterator it = races.begin() + MWWorld::Store<ESM::Race>::iterator it = races.begin(); for (; it != races.end(); ++it) { bool playable = it->mData.mFlags & ESM::Race::Playable; diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 5d30b142a0..9d6842068e 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -456,7 +456,8 @@ void StatsWindow::updateSkillArea() FactionList::const_iterator end = mFactions.end(); for (FactionList::const_iterator it = mFactions.begin(); it != end; ++it) { - const ESM::Faction *faction = store.factions.find(it->first); + const ESM::Faction *faction = + store.get<ESM::Faction>().find(it->first); MyGUI::Widget* w = addItem(faction->mName, coord1, coord2); std::string text; @@ -507,7 +508,8 @@ void StatsWindow::updateSkillArea() addSeparator(coord1, coord2); addGroup(mWindowManager.getGameSettingString("sBirthSign", "Sign"), coord1, coord2); - const ESM::BirthSign *sign = store.birthSigns.find(mBirthSignId); + const ESM::BirthSign *sign = + store.get<ESM::BirthSign>().find(mBirthSignId); MyGUI::Widget* w = addItem(sign->mName, coord1, coord2); ToolTips::createBirthsignToolTip(w, mBirthSignId); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index d1e3602b79..2c2efa4870 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -33,7 +33,7 @@ namespace MWRender // get the size of the world MWWorld::Store<ESM::Cell>::iterator it = esmStore.get<ESM::Cell>().extBegin(); - for (; it != esmStore.get<ESM::Cell>().end(); ++it) + for (; it != esmStore.get<ESM::Cell>().extEnd(); ++it) { if (it->getGridX() < mMinX) mMinX = it->getGridX(); diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index c4d70ba08e..58039e2496 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -63,11 +63,11 @@ namespace MWWorld return iter; } - SharedIterator operator==(const SharedIterator &x) const { + bool operator==(const SharedIterator &x) const { return mIter == x.mIter; } - SharedIterator operator!=(const SharedIterator &x) const { + bool operator!=(const SharedIterator &x) const { return !(*this == x); } @@ -314,20 +314,20 @@ namespace MWWorld return iterator(mStatic.end()); } - ESM::Land *search(int x, int y) { + ESM::Land *search(int x, int y) const { ESM::Land land; land.mX = x, land.mY = y; - std::vector<ESM::Land *>::iterator it = + std::vector<ESM::Land *>::const_iterator it = std::lower_bound(mStatic.begin(), mStatic.end(), &land, Compare()); if (it != mStatic.end() && (*it)->mX == x && (*it)->mY == y) { - return *it; + return const_cast<ESM::Land *>(*it); } return 0; } - ESM::Land *find(int x, int y) { + ESM::Land *find(int x, int y) const{ ESM::Land *ptr = search(x, y); if (ptr == 0) { std::ostringstream msg; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 02fac8b619..9a1303d764 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -775,6 +775,7 @@ namespace MWWorld std::pair<std::string, const ESM::Potion *> World::createRecord (const ESM::Potion& record) { + /* /// \todo Rewrite the ESMStore so that a dynamic 2nd ESMStore can be attached to it. /// This function should then insert the record into the 2nd store (the code for this /// should also be moved to the ESMStore class). It might be a good idea to review @@ -792,10 +793,10 @@ namespace MWWorld mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH)); return std::make_pair (stream.str(), created); - } + */} std::pair<std::string, const ESM::Class *> World::createRecord (const ESM::Class& record) - { + {/* /// \todo See function above. std::ostringstream stream; stream << "$dynamic" << mNextDynamicRecord++; @@ -806,10 +807,10 @@ namespace MWWorld mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS)); return std::make_pair (stream.str(), created); - } + */} std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record) - { + {/* /// \todo See function above. std::ostringstream stream; stream << "$dynamic" << mNextDynamicRecord++; @@ -820,10 +821,10 @@ namespace MWWorld mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL)); return std::make_pair (stream.str(), created); - } + */} const ESM::Cell *World::createRecord (const ESM::Cell& record) - { + {/* if (record.mData.mFlags & ESM::Cell::Interior) { if (mStore.cells.searchInt (record.mName)) @@ -843,7 +844,7 @@ namespace MWWorld std::make_pair (std::make_pair (record.mData.mX, record.mData.mY), cell)); return cell; } - } + */} void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number) From b3ad8728457c37302ccf3125a6c1745752a7cd0e Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 13:43:48 +0400 Subject: [PATCH 144/255] new interface in manualref, fix various typos --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 5 +- apps/openmw/mwdialogue/journalentry.cpp | 3 +- apps/openmw/mwgui/container.cpp | 2 +- apps/openmw/mwgui/trainingwindow.cpp | 5 +- apps/openmw/mwmechanics/spellsuccess.hpp | 2 +- apps/openmw/mwscript/compilercontext.cpp | 2 +- apps/openmw/mwscript/globalscripts.cpp | 10 ++-- apps/openmw/mwscript/scriptmanagerimp.cpp | 2 +- apps/openmw/mwworld/manualref.hpp | 59 +++++++------------ apps/openmw/mwworld/store.hpp | 2 +- 10 files changed, 41 insertions(+), 51 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 059c1ce88c..7e9525e61b 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -90,7 +90,8 @@ namespace if (scriptName.empty()) return false; // no script - const ESM::Script *script = store.scripts.find (scriptName); + const ESM::Script *script = + store.get<ESM::Script>().find (scriptName); int i = 0; @@ -751,7 +752,7 @@ namespace MWDialogue MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); - MWWordl::Store<ESM::Dialogue>::iterator it = dialogs.begin(); + MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) { if(it->mType == ESM::Dialogue::Topic) diff --git a/apps/openmw/mwdialogue/journalentry.cpp b/apps/openmw/mwdialogue/journalentry.cpp index df9129b4d5..e6141884cb 100644 --- a/apps/openmw/mwdialogue/journalentry.cpp +++ b/apps/openmw/mwdialogue/journalentry.cpp @@ -18,7 +18,8 @@ namespace MWDialogue std::string JournalEntry::getText (const MWWorld::ESMStore& store) const { - const ESM::Dialogue *dialogue = store.dialogs.find (mTopic); + const ESM::Dialogue *dialogue = + store.get<ESM::Dialogue>().find (mTopic); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); iter!=dialogue->mInfo.end(); ++iter) diff --git a/apps/openmw/mwgui/container.cpp b/apps/openmw/mwgui/container.cpp index db286a7fca..20bc95445b 100644 --- a/apps/openmw/mwgui/container.cpp +++ b/apps/openmw/mwgui/container.cpp @@ -128,7 +128,7 @@ void ContainerBase::onSelectedItem(MyGUI::Widget* _sender) if (isInventory()) { const MWWorld::Store<ESM::GameSetting> &gmst = - MWWorld::Environment::get().getWorld()->getStore()->get<ESM::GameSetting>(); + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); // the player is trying to sell an item, check if the merchant accepts it // also, don't allow selling gold (let's be better than Morrowind at this, can we?) diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 08e64eba88..1e9841afb0 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -73,10 +73,13 @@ namespace MWGui MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer ().getPlayer (); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + for (int i=0; i<3; ++i) { /// \todo mercantile skill - int price = pcStats.getSkill (bestSkills[i].first).getBase() * MWBase::Environment::get().getWorld ()->getStore ().gameSettings.find("iTrainingMod")->getInt (); + int price = pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (); std::string skin = (price > mWindowManager.getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton"; diff --git a/apps/openmw/mwmechanics/spellsuccess.hpp b/apps/openmw/mwmechanics/spellsuccess.hpp index 2dacee57b9..57c600df50 100644 --- a/apps/openmw/mwmechanics/spellsuccess.hpp +++ b/apps/openmw/mwmechanics/spellsuccess.hpp @@ -63,7 +63,7 @@ namespace MWMechanics inline int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor) { const ESM::Spell* spell = - MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell.().find(spellId); + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); return getSpellSchool(spell, actor); } diff --git a/apps/openmw/mwscript/compilercontext.cpp b/apps/openmw/mwscript/compilercontext.cpp index d568cab219..57d93512f4 100644 --- a/apps/openmw/mwscript/compilercontext.cpp +++ b/apps/openmw/mwscript/compilercontext.cpp @@ -51,7 +51,7 @@ namespace MWScript store.get<ESM::Apparatus>().search (name) || store.get<ESM::Armor>().search (name) || store.get<ESM::Book>().search (name) || - store.get<ESM::Cloth>().search (name) || + store.get<ESM::Clothing>().search (name) || store.get<ESM::Container>().search (name) || store.get<ESM::Creature>().search (name) || store.get<ESM::Door>().search (name) || diff --git a/apps/openmw/mwscript/globalscripts.cpp b/apps/openmw/mwscript/globalscripts.cpp index b8287e7a3b..3ef138432d 100644 --- a/apps/openmw/mwscript/globalscripts.cpp +++ b/apps/openmw/mwscript/globalscripts.cpp @@ -17,10 +17,12 @@ namespace MWScript { addScript ("Main"); - for (MWWorld::RecListT<ESM::StartScript>::MapType::const_iterator iter - (store.startScripts.list.begin()); - iter != store.startScripts.list.end(); ++iter) - addScript (iter->second.mScript); + MWWorld::Store<ESM::StartScript>::iterator iter = + store.get<ESM::StartScript>().begin(); + + for (; iter != store.get<ESM::StartScript>().end(); ++iter) { + addScript (iter->mScript); + } } void GlobalScripts::addScript (const std::string& name) diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index 5d29e6e016..1f338edbd3 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -131,7 +131,7 @@ namespace MWScript const MWWorld::Store<ESM::Script>& scripts = mStore.get<ESM::Script>(); MWWorld::Store<ESM::Script>::iterator it = scripts.begin(); - for (; it != scripts.end(); ++iter, ++count) + for (; it != scripts.end(); ++it, ++count) if (compile (it->mId)) ++success; diff --git a/apps/openmw/mwworld/manualref.hpp b/apps/openmw/mwworld/manualref.hpp index 88d0e90fc3..91b8cf8cd4 100644 --- a/apps/openmw/mwworld/manualref.hpp +++ b/apps/openmw/mwworld/manualref.hpp @@ -19,24 +19,7 @@ namespace MWWorld ManualRef& operator= (const ManualRef&); template<typename T> - bool create (const MWWorld::RecListT<T>& list, const std::string& name) - { - if (const T *instance = list.search (name)) - { - LiveCellRef<T> ref; - ref.mBase = instance; - - mRef = ref; - mPtr = Ptr (&boost::any_cast<LiveCellRef<T>&> (mRef), 0); - - return true; - } - - return false; - } - - template<typename T> - bool create (const MWWorld::RecListWithIDT<T>& list, const std::string& name) + bool create (const MWWorld::Store<T>& list, const std::string& name) { if (const T *instance = list.search (name)) { @@ -57,26 +40,26 @@ namespace MWWorld ManualRef (const MWWorld::ESMStore& store, const std::string& name) { // create - if (!create (store.activators, name) && - !create (store.potions, name) && - !create (store.appas, name) && - !create (store.armors, name) && - !create (store.books, name) && - !create (store.clothes, name) && - !create (store.containers, name) && - !create (store.creatures, name) && - !create (store.doors, name) && - !create (store.ingreds, name) && - !create (store.creatureLists, name) && - !create (store.itemLists, name) && - !create (store.lights, name) && - !create (store.lockpicks, name) && - !create (store.miscItems, name) && - !create (store.npcs, name) && - !create (store.probes, name) && - !create (store.repairs, name) && - !create (store.statics, name) && - !create (store.weapons, name)) + if (!create (store.get<ESM::Activator>(), name) && + !create (store.get<ESM::Potion>(), name) && + !create (store.get<ESM::Apparatus>(), name) && + !create (store.get<ESM::Armor>(), name) && + !create (store.get<ESM::Book>(), name) && + !create (store.get<ESM::Clothing>(), name) && + !create (store.get<ESM::Container>(), name) && + !create (store.get<ESM::Creature>(), name) && + !create (store.get<ESM::Door>(), name) && + !create (store.get<ESM::Ingredient>(), name) && + !create (store.get<ESM::CreatureLevList>(), name) && + !create (store.get<ESM::ItemLevList>(), name) && + !create (store.get<ESM::Light>(), name) && + !create (store.get<ESM::Tool>(), name) && + !create (store.get<ESM::Miscellaneous>(), name) && + !create (store.get<ESM::NPC>(), name) && + !create (store.get<ESM::Probe>(), name) && + !create (store.get<ESM::Repair>(), name) && + !create (store.get<ESM::Static>(), name) && + !create (store.get<ESM::Weapon>(), name)) throw std::logic_error ("failed to create manual cell ref for " + name); // initialise diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 58039e2496..5171621feb 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -844,7 +844,7 @@ namespace MWWorld } const T *find(int index) const { - T *ptr = search(index); + const T *ptr = search(index); if (ptr == 0) { std::ostringstream msg; msg << "Object with index " << index << " not found"; From 242a9b5a59d4e8676b647176b996fe4c3cfae75c Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 14:03:36 +0400 Subject: [PATCH 145/255] various interface fixes, commented unused code --- apps/openmw/mwworld/cells.cpp | 6 ++--- apps/openmw/mwworld/globals.cpp | 15 ++++++------ apps/openmw/mwworld/worldimp.cpp | 42 +++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index beed6f1d76..696a469f76 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -269,7 +269,7 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) for (iter = cells.intBegin(); iter != cells.intEnd(); ++iter) { - Ptr::CellStore *cellStore = getCellStore (*iter); + Ptr::CellStore *cellStore = getCellStore (&(*iter)); Ptr ptr = getPtrAndCache (name, *cellStore); @@ -277,9 +277,9 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name) return ptr; } - for (iter = cells.extBegin(); iter != cells.extEnd(); ++it) + for (iter = cells.extBegin(); iter != cells.extEnd(); ++iter) { - Ptr::CellStore *cellStore = getCellStore (*iter); + Ptr::CellStore *cellStore = getCellStore (&(*iter)); Ptr ptr = getPtrAndCache (name, *cellStore); diff --git a/apps/openmw/mwworld/globals.cpp b/apps/openmw/mwworld/globals.cpp index f904dd2b15..76dede5a34 100644 --- a/apps/openmw/mwworld/globals.cpp +++ b/apps/openmw/mwworld/globals.cpp @@ -29,33 +29,34 @@ namespace MWWorld Globals::Globals (const MWWorld::ESMStore& store) { - for (MWWorld::RecListT<ESM::Global>::MapType::const_iterator iter - (store.globals.list.begin()); iter != store.globals.list.end(); ++iter) + const MWWorld::Store<ESM::Global> &globals = store.get<ESM::Global>(); + MWWorld::Store<ESM::Global>::iterator iter = globals.begin(); + for (; iter != globals.end(); ++iter) { char type = ' '; Data value; - switch (iter->second.mType) + switch (iter->mType) { case ESM::VT_Short: type = 's'; value.mShort = *reinterpret_cast<const Interpreter::Type_Float *> ( - &iter->second.mValue); + &iter->mValue); break; case ESM::VT_Int: type = 'l'; value.mLong = *reinterpret_cast<const Interpreter::Type_Float *> ( - &iter->second.mValue); + &iter->mValue); break; case ESM::VT_Float: type = 'f'; value.mFloat = *reinterpret_cast<const Interpreter::Type_Float *> ( - &iter->second.mValue); + &iter->mValue); break; default: @@ -63,7 +64,7 @@ namespace MWWorld throw std::runtime_error ("unsupported global variable type"); } - mVariables.insert (std::make_pair (iter->first, std::make_pair (type, value))); + mVariables.insert (std::make_pair (iter->mId, std::make_pair (type, value))); } if (mVariables.find ("dayspassed")==mVariables.end()) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 9a1303d764..4e98b36820 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -19,6 +19,9 @@ using namespace Ogre; namespace { +/* // NOTE this code is never instantiated (proper copy in localscripts.cpp), + // so this commented out to not produce syntactic errors + template<typename T> void listCellScripts (const MWWorld::ESMStore& store, MWWorld::CellRefList<T>& cellRefList, MWWorld::LocalScripts& localScripts, @@ -28,18 +31,18 @@ namespace cellRefList.mList.begin()); iter!=cellRefList.mList.end(); ++iter) { - if (!iter->mBase->script.empty() && iter->mData.getCount()) + if (!iter->mBase->mScript.empty() && iter->mData.getCount()) { - if (const ESM::Script *script = store.scripts.find (iter->base->script)) + if (const ESM::Script *script = store.get<ESM::Script>().find (iter->mBase->mScript)) { iter->mData.setLocals (*script); - localScripts.add (iter->base->script, MWWorld::Ptr (&*iter, cell)); + localScripts.add (iter->mBase->mScript, MWWorld::Ptr (&*iter, cell)); } } } } - +*/ template<typename T> MWWorld::LiveCellRef<T> *searchViaHandle (const std::string& handle, MWWorld::CellRefList<T>& refList) @@ -793,10 +796,15 @@ namespace MWWorld mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH)); return std::make_pair (stream.str(), created); - */} + */ + std::string id = ""; + const ESM::Potion *ptr = 0; + return std::make_pair(id, ptr); + } std::pair<std::string, const ESM::Class *> World::createRecord (const ESM::Class& record) - {/* + { + /* /// \todo See function above. std::ostringstream stream; stream << "$dynamic" << mNextDynamicRecord++; @@ -807,10 +815,15 @@ namespace MWWorld mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS)); return std::make_pair (stream.str(), created); - */} + */ + std::string id = ""; + const ESM::Class *ptr = 0; + return std::make_pair(id, ptr); + } std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record) - {/* + { + /* /// \todo See function above. std::ostringstream stream; stream << "$dynamic" << mNextDynamicRecord++; @@ -821,10 +834,15 @@ namespace MWWorld mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL)); return std::make_pair (stream.str(), created); - */} + */ + std::string id = ""; + const ESM::Spell *ptr = 0; + return std::make_pair(id, ptr); + } const ESM::Cell *World::createRecord (const ESM::Cell& record) - {/* + { + /* if (record.mData.mFlags & ESM::Cell::Interior) { if (mStore.cells.searchInt (record.mName)) @@ -844,7 +862,9 @@ namespace MWWorld std::make_pair (std::make_pair (record.mData.mX, record.mData.mY), cell)); return cell; } - */} + */ + return 0; + } void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number) From 0fd22ce4b092d8fde5105a2c7a75b6a34cd4a785 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 14:23:21 +0400 Subject: [PATCH 146/255] CellRefList<X>::find(CellRef &, Y &list) -> ::load(CellRef &, ESMStore &) --- apps/openmw/mwworld/cellstore.cpp | 40 +++++++++++++++---------------- apps/openmw/mwworld/cellstore.hpp | 22 ++++++++++------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index db9761b760..1ef2d36a26 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -98,26 +98,26 @@ namespace MWWorld */ switch(rec) { - case ESM::REC_ACTI: mActivators.find(ref, store.activators); break; - case ESM::REC_ALCH: mPotions.find(ref, store.potions); break; - case ESM::REC_APPA: mAppas.find(ref, store.appas); break; - case ESM::REC_ARMO: mArmors.find(ref, store.armors); break; - case ESM::REC_BOOK: mBooks.find(ref, store.books); break; - case ESM::REC_CLOT: mClothes.find(ref, store.clothes); break; - case ESM::REC_CONT: mContainers.find(ref, store.containers); break; - case ESM::REC_CREA: mCreatures.find(ref, store.creatures); break; - case ESM::REC_DOOR: mDoors.find(ref, store.doors); break; - case ESM::REC_INGR: mIngreds.find(ref, store.ingreds); break; - case ESM::REC_LEVC: mCreatureLists.find(ref, store.creatureLists); break; - case ESM::REC_LEVI: mItemLists.find(ref, store.itemLists); break; - case ESM::REC_LIGH: mLights.find(ref, store.lights); break; - case ESM::REC_LOCK: mLockpicks.find(ref, store.lockpicks); break; - case ESM::REC_MISC: mMiscItems.find(ref, store.miscItems); break; - case ESM::REC_NPC_: mNpcs.find(ref, store.npcs); break; - case ESM::REC_PROB: mProbes.find(ref, store.probes); break; - case ESM::REC_REPA: mRepairs.find(ref, store.repairs); break; - case ESM::REC_STAT: mStatics.find(ref, store.statics); break; - case ESM::REC_WEAP: mWeapons.find(ref, store.weapons); break; + case ESM::REC_ACTI: mActivators.load(ref, store); break; + case ESM::REC_ALCH: mPotions.load(ref, store); break; + case ESM::REC_APPA: mAppas.load(ref, store); break; + case ESM::REC_ARMO: mArmors.load(ref, store); break; + case ESM::REC_BOOK: mBooks.load(ref, store); break; + case ESM::REC_CLOT: mClothes.load(ref, store); break; + case ESM::REC_CONT: mContainers.load(ref, store); break; + case ESM::REC_CREA: mCreatures.load(ref, store); break; + case ESM::REC_DOOR: mDoors.load(ref, store); break; + case ESM::REC_INGR: mIngreds.load(ref, store); break; + case ESM::REC_LEVC: mCreatureLists.load(ref, store); break; + case ESM::REC_LEVI: mItemLists.load(ref, store); break; + case ESM::REC_LIGH: mLights.load(ref, store); break; + case ESM::REC_LOCK: mLockpicks.load(ref, store); break; + case ESM::REC_MISC: mMiscItems.load(ref, store); break; + case ESM::REC_NPC_: mNpcs.load(ref, store); break; + case ESM::REC_PROB: mProbes.load(ref, store); break; + case ESM::REC_REPA: mRepairs.load(ref, store); break; + case ESM::REC_STAT: mStatics.load(ref, store); break; + case ESM::REC_WEAP: mWeapons.load(ref, store); break; case 0: std::cout << "Cell reference " + ref.mRefID + " not found!\n"; break; default: diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 440ab0690d..ba3d24d7ef 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -7,6 +7,7 @@ #include <algorithm> #include "refdata.hpp" +#include "esmstore.hpp" namespace MWWorld { @@ -50,17 +51,20 @@ namespace MWWorld typedef std::list<LiveRef> List; List mList; - // Search for the given reference in the given reclist from - // ESMStore. Insert the reference into the list if a match is - // found. If not, throw an exception. - template <typename Y> - void find(ESM::CellRef &ref, const Y& recList) + /// Searches for reference of appropriate type in given ESMStore. + /// If reference exists, loads it into container, throws an exception + /// on miss + void load(ESM::CellRef &ref, const MWWorld::ESMStore &esmStore) { - const X* obj = recList.find(ref.mRefID); - if(obj == NULL) - throw std::runtime_error("Error resolving cell reference " + ref.mRefID); + // for throwing exception on unhandled record type + const MWWorld::Store<X> &store = esmStore.get<X>(); + const X *ptr = store.find(ref.mRefID); - mList.push_back(LiveRef(ref, obj)); + /// \note redundant because Store<X>::find() throws exception on miss + if (ptr == NULL) { + throw std::runtime_error("Error resolving cell reference " + ref.mRefID); + } + mList.push_back(LiveRef(ref, ptr)); } LiveRef *find (const std::string& name) From 620184a00949786979178ca800dc7a12f45bd3f1 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 14:44:56 +0400 Subject: [PATCH 147/255] fix typos --- apps/openmw/mwclass/armor.cpp | 2 +- apps/openmw/mwclass/misc.cpp | 2 +- apps/openmw/mwmechanics/spells.cpp | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 3b82f9c48c..f562aee5eb 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -161,7 +161,7 @@ namespace MWClass ref->mBase->mData.mWeight) return ESM::Skill::LightArmor; - if (iWeight * gmst.get<ESM::GameSetting>().find ("fMedMaxMod")->getFloat()>= + if (iWeight * gmst.find ("fMedMaxMod")->getFloat()>= ref->mBase->mData.mWeight) return ESM::Skill::MediumArmor; diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 9aa02530fc..18fd8819a5 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -192,7 +192,7 @@ namespace MWClass const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - if (MWWorld::Class::get(ptr).getName(ptr) == store.get<ESM::GameSetting().find("sGold")->getString()) { + if (MWWorld::Class::get(ptr).getName(ptr) == store.get<ESM::GameSetting>().find("sGold")->getString()) { int goldAmount = ptr.getRefData().getCount(); std::string base = "Gold_001"; diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index b883abaf07..3ff10cdb87 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -50,7 +50,8 @@ namespace MWMechanics for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) { - const ESM::Spell *spell = MWBase::Environment::get().getWorld()->getStore().spells.find (*iter); + const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); if (spell->mData.mType==ESM::Spell::ST_Ability || spell->mData.mType==ESM::Spell::ST_Blight || spell->mData.mType==ESM::Spell::ST_Disease || spell->mData.mType==ESM::Spell::ST_Curse) From 18bb5960e410062802449489a0f8b75921e343d1 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 15:10:57 +0400 Subject: [PATCH 148/255] let's rescue linker --- apps/openmw/mwworld/esmstore.hpp | 90 +++++++++++++++---------------- apps/openmw/mwworld/recordcmp.hpp | 6 +-- apps/openmw/mwworld/store.hpp | 12 +---- 3 files changed, 50 insertions(+), 58 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 6073bc6d94..0c97ca1883 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -145,227 +145,227 @@ namespace MWWorld }; template <> - const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { + inline const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { return mActivators; } template <> - const Store<ESM::Potion> &ESMStore::get<ESM::Potion>() const { + inline const Store<ESM::Potion> &ESMStore::get<ESM::Potion>() const { return mPotions; } template <> - const Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() const { + inline const Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() const { return mAppas; } template <> - const Store<ESM::Armor> &ESMStore::get<ESM::Armor>() const { + inline const Store<ESM::Armor> &ESMStore::get<ESM::Armor>() const { return mArmors; } template <> - const Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() const { + inline const Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() const { return mBodyParts; } template <> - const Store<ESM::Book> &ESMStore::get<ESM::Book>() const { + inline const Store<ESM::Book> &ESMStore::get<ESM::Book>() const { return mBooks; } template <> - const Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() const { + inline const Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() const { return mBirthSigns; } template <> - const Store<ESM::Class> &ESMStore::get<ESM::Class>() const { + inline const Store<ESM::Class> &ESMStore::get<ESM::Class>() const { return mClasses; } template <> - const Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() const { + inline const Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() const { return mClothes; } template <> - const Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() const { + inline const Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() const { return mContChange; } template <> - const Store<ESM::Container> &ESMStore::get<ESM::Container>() const { + inline const Store<ESM::Container> &ESMStore::get<ESM::Container>() const { return mContainers; } template <> - const Store<ESM::Creature> &ESMStore::get<ESM::Creature>() const { + inline const Store<ESM::Creature> &ESMStore::get<ESM::Creature>() const { return mCreatures; } template <> - const Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() const { + inline const Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() const { return mCreaChange; } template <> - const Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() const { + inline const Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() const { return mDialogs; } template <> - const Store<ESM::Door> &ESMStore::get<ESM::Door>() const { + inline const Store<ESM::Door> &ESMStore::get<ESM::Door>() const { return mDoors; } template <> - const Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() const { + inline const Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() const { return mEnchants; } template <> - const Store<ESM::Faction> &ESMStore::get<ESM::Faction>() const { + inline const Store<ESM::Faction> &ESMStore::get<ESM::Faction>() const { return mFactions; } template <> - const Store<ESM::Global> &ESMStore::get<ESM::Global>() const { + inline const Store<ESM::Global> &ESMStore::get<ESM::Global>() const { return mGlobals; } template <> - const Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() const { + inline const Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() const { return mIngreds; } template <> - const Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() const { + inline const Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() const { return mCreatureLists; } template <> - const Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() const { + inline const Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() const { return mItemLists; } template <> - const Store<ESM::Light> &ESMStore::get<ESM::Light>() const { + inline const Store<ESM::Light> &ESMStore::get<ESM::Light>() const { return mLights; } template <> - const Store<ESM::Tool> &ESMStore::get<ESM::Tool>() const { + inline const Store<ESM::Tool> &ESMStore::get<ESM::Tool>() const { return mLockpicks; } template <> - const Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() const { + inline const Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() const { return mMiscItems; } template <> - const Store<ESM::NPC> &ESMStore::get<ESM::NPC>() const { + inline const Store<ESM::NPC> &ESMStore::get<ESM::NPC>() const { return mNpcs; } template <> - const Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() const { + inline const Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() const { return mNpcChange; } template <> - const Store<ESM::Probe> &ESMStore::get<ESM::Probe>() const { + inline const Store<ESM::Probe> &ESMStore::get<ESM::Probe>() const { return mProbes; } template <> - const Store<ESM::Race> &ESMStore::get<ESM::Race>() const { + inline const Store<ESM::Race> &ESMStore::get<ESM::Race>() const { return mRaces; } template <> - const Store<ESM::Region> &ESMStore::get<ESM::Region>() const { + inline const Store<ESM::Region> &ESMStore::get<ESM::Region>() const { return mRegions; } template <> - const Store<ESM::Repair> &ESMStore::get<ESM::Repair>() const { + inline const Store<ESM::Repair> &ESMStore::get<ESM::Repair>() const { return mRepairs; } template <> - const Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() const { + inline const Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() const { return mSoundGens; } template <> - const Store<ESM::Sound> &ESMStore::get<ESM::Sound>() const { + inline const Store<ESM::Sound> &ESMStore::get<ESM::Sound>() const { return mSounds; } template <> - const Store<ESM::Spell> &ESMStore::get<ESM::Spell>() const { + inline const Store<ESM::Spell> &ESMStore::get<ESM::Spell>() const { return mSpells; } template <> - const Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() const { + inline const Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() const { return mStartScripts; } template <> - const Store<ESM::Static> &ESMStore::get<ESM::Static>() const { + inline const Store<ESM::Static> &ESMStore::get<ESM::Static>() const { return mStatics; } template <> - const Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() const { + inline const Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() const { return mWeapons; } template <> - const Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() const { + inline const Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() const { return mGameSettings; } template <> - const Store<ESM::Script> &ESMStore::get<ESM::Script>() const { + inline const Store<ESM::Script> &ESMStore::get<ESM::Script>() const { return mScripts; } template <> - const Store<ESM::Cell> &ESMStore::get<ESM::Cell>() const { + inline const Store<ESM::Cell> &ESMStore::get<ESM::Cell>() const { return mCells; } template <> - const Store<ESM::Land> &ESMStore::get<ESM::Land>() const { + inline const Store<ESM::Land> &ESMStore::get<ESM::Land>() const { return mLands; } template <> - const Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() const { + inline const Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() const { return mLandTextures; } template <> - const Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() const { + inline const Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() const { return mPathgrids; } template <> - const Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() const { + inline const Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() const { return mMagicEffects; } template <> - const Store<ESM::Skill> &ESMStore::get<ESM::Skill>() const { + inline const Store<ESM::Skill> &ESMStore::get<ESM::Skill>() const { return mSkills; } template <> - const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { + inline const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { return mAttributes; } } diff --git a/apps/openmw/mwworld/recordcmp.hpp b/apps/openmw/mwworld/recordcmp.hpp index 0e2871ba50..0b16551005 100644 --- a/apps/openmw/mwworld/recordcmp.hpp +++ b/apps/openmw/mwworld/recordcmp.hpp @@ -66,17 +66,17 @@ namespace MWWorld }; template <> - bool RecordCmp::operator()<ESM::Dialogue>(const ESM::Dialogue &x, const ESM::Dialogue &y) const { + inline bool RecordCmp::operator()<ESM::Dialogue>(const ESM::Dialogue &x, const ESM::Dialogue &y) const { return StringUtils::ciLess(x.mId, y.mId); } template <> - bool RecordCmp::operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) const { + inline bool RecordCmp::operator()<ESM::Cell>(const ESM::Cell &x, const ESM::Cell &y) const { return StringUtils::ciLess(x.mName, y.mName); } template <> - bool RecordCmp::operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &y) const { + inline bool RecordCmp::operator()<ESM::Pathgrid>(const ESM::Pathgrid &x, const ESM::Pathgrid &y) const { return StringUtils::ciLess(x.mCell, y.mCell); } diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 5171621feb..12f7c7f01a 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -218,18 +218,10 @@ namespace MWWorld }; template <> - void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id) { - mStatic.push_back(ESM::Dialogue()); - mStatic.back().mId = id; - mStatic.back().load(esm); - } + void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id); template <> - void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id) { - mStatic.push_back(ESM::Script()); - mStatic.back().load(esm); - StringUtils::toLower(mStatic.back().mId); - } + void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id); template <> class Store<ESM::LandTexture> : public StoreBase From dccc157f4c619e17fb968bf86adad048f4144919 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 15:26:55 +0400 Subject: [PATCH 149/255] setting up --- apps/openmw/mwworld/esmstore.cpp | 4 ++-- apps/openmw/mwworld/store.hpp | 4 ++++ apps/openmw/mwworld/worldimp.cpp | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index eb236d1bc2..a69a8fde72 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -60,8 +60,8 @@ void ESMStore::load(ESM::ESMReader &esm) if (n.val==ESM::REC_DIAL) { // dirty hack, but it is better than non-const search() // or friends - dialogue = const_cast<ESM::Dialogue *>(mDialogs.search(id)); - assert (dialogue != NULL); + dialogue = &mDialogs.mStatic.back(); + assert (dialogue->mId == id); } else { dialogue = 0; } diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 12f7c7f01a..1adc2677eb 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -80,6 +80,8 @@ namespace MWWorld } }; + class ESMStore; + template <class T> class Store : public StoreBase { @@ -89,6 +91,8 @@ namespace MWWorld typedef std::map<std::string, T> Dynamic; + friend class ESMStore; + public: Store() {} diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4e98b36820..2b212c3db6 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -188,6 +188,7 @@ namespace MWWorld mEsm.setEncoding(encoding); mEsm.open (masterPath.string()); mStore.load (mEsm); + mStore.setUp(); mPlayer = new MWWorld::Player (mStore.get<ESM::NPC>().find ("player"), *this); mRendering->attachCameraTo(mPlayer->getPlayer()); From 6d5333be050667aa1bd908480ac574947e8c0406 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 6 Nov 2012 13:08:25 +0100 Subject: [PATCH 150/255] some code cleanup --- apps/openmw/mwrender/renderingmanager.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 1b9f46781a..426cc47903 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -242,13 +242,7 @@ void RenderingManager::addObject (const MWWorld::Ptr& ptr){ void RenderingManager::removeObject (const MWWorld::Ptr& ptr) { if (!mObjects.deleteObject (ptr)) - { - /// \todo delete non-object MW-references - } - if (!mActors.deleteObject (ptr)) - { - /// \todo delete non-object MW-references - } + mActors.deleteObject (ptr); } void RenderingManager::moveObject (const MWWorld::Ptr& ptr, const Ogre::Vector3& position) @@ -292,9 +286,11 @@ bool RenderingManager::rotateObject( const MWWorld::Ptr &ptr, Ogre::Vector3 &rot } else if (adjust) { - /// \note Stored and passed in radians + // Stored and passed in radians float *f = ptr.getRefData().getPosition().rot; - rot.x += f[0], rot.y += f[1], rot.z += f[2]; + rot.x += f[0]; + rot.y += f[1]; + rot.z += f[2]; } return force; } @@ -365,7 +361,7 @@ void RenderingManager::update (float duration, bool paused) float *fpos = data.getPosition().pos; - /// \note only for LocalMap::updatePlayer() + // only for LocalMap::updatePlayer() Ogre::Vector3 pos(fpos[0], -fpos[2], -fpos[1]); Ogre::SceneNode *node = data.getBaseNode(); From bf98b95955fd66f758fb7d1e73ae9d22f40c437b Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Tue, 6 Nov 2012 13:10:54 +0100 Subject: [PATCH 151/255] bugfix --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 3f76f48a68..b65b7573b4 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -353,7 +353,8 @@ namespace MWMechanics float reaction = 0; int rank = 0; - std::string npcFaction = npcSkill.getFactionRanks().begin()->first; + std::string npcFaction = ""; + if(!npcSkill.getFactionRanks().empty()) npcFaction = npcSkill.getFactionRanks().begin()->first; const ESMS::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); if (playerSkill.getFactionRanks().find(toLower(npcFaction)) != playerSkill.getFactionRanks().end()) From 9f1733a415ac91b75f240bd7c5d30c710acaaa71 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 17:51:38 +0400 Subject: [PATCH 152/255] move record insertion to ESMStore --- apps/openmw/mwworld/esmstore.hpp | 27 +++++++++++ apps/openmw/mwworld/worldimp.cpp | 83 +++----------------------------- apps/openmw/mwworld/worldimp.hpp | 1 - 3 files changed, 35 insertions(+), 76 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 0c97ca1883..46c156ffb8 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -67,6 +67,8 @@ namespace MWWorld std::map<std::string, int> mIds; std::map<int, StoreBase *> mStores; + unsigned int mDynamicCount; + public: /// \todo replace with SharedIterator<StoreBase> typedef std::map<int, StoreBase *>::const_iterator iterator; @@ -90,6 +92,7 @@ namespace MWWorld } ESMStore() + : mDynamicCount(0) { mStores[ESM::REC_ACTI] = &mActivators; mStores[ESM::REC_ALCH] = &mPotions; @@ -142,8 +145,32 @@ namespace MWWorld const Store<T> &get() const { throw std::runtime_error("Storage for this type not exist"); } + + template <class T> + T *insert(const T &x) { + Store<T> &store = const_cast<Store<T> &>(get<T>()); + T record = x; + + std::ostringstream id; + id << "$dynamic" << mDynamicCount++; + record.mId = id.str(); + + T *ptr = store.insert(record); + for (iterator it = mStores.begin(); it != mStores.end(); ++it) { + if (it->second == &store) { + mIds[ptr->mId] = it->first; + } + } + return ptr; + } + }; + template <> + inline ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) { + return mCells.insert(cell); + } + template <> inline const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { return mActivators; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 2b212c3db6..00f16743c7 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -170,7 +170,7 @@ namespace MWWorld const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame, const std::string& encoding, std::map<std::string,std::string> fallbackMap) : mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0), - mSky (true), mNextDynamicRecord (0), mCells (mStore, mEsm), + mSky (true), mCells (mStore, mEsm), mNumFacing(0) { mPhysics = new PhysicsSystem(renderer); @@ -779,92 +779,25 @@ namespace MWWorld std::pair<std::string, const ESM::Potion *> World::createRecord (const ESM::Potion& record) { - /* - /// \todo Rewrite the ESMStore so that a dynamic 2nd ESMStore can be attached to it. - /// This function should then insert the record into the 2nd store (the code for this - /// should also be moved to the ESMStore class). It might be a good idea to review - /// the STL-container usage of the ESMStore before the rewrite. - - std::ostringstream stream; - stream << "$dynamic" << mNextDynamicRecord++; - - ESM::Potion record2 (record); - record2.mId = stream.str(); - - const ESM::Potion *created = - &mStore.potions.list.insert (std::make_pair (stream.str(), record2)).first->second; - - mStore.all.insert (std::make_pair (stream.str(), ESM::REC_ALCH)); - - return std::make_pair (stream.str(), created); - */ - std::string id = ""; - const ESM::Potion *ptr = 0; - return std::make_pair(id, ptr); + const ESM::Potion *ptr = mStore.insert(record); + return std::make_pair(ptr->mId, ptr); } std::pair<std::string, const ESM::Class *> World::createRecord (const ESM::Class& record) { - /* - /// \todo See function above. - std::ostringstream stream; - stream << "$dynamic" << mNextDynamicRecord++; - - const ESM::Class *created = - &mStore.classes.list.insert (std::make_pair (stream.str(), record)).first->second; - - mStore.all.insert (std::make_pair (stream.str(), ESM::REC_CLAS)); - - return std::make_pair (stream.str(), created); - */ - std::string id = ""; - const ESM::Class *ptr = 0; - return std::make_pair(id, ptr); + const ESM::Class *ptr = mStore.insert(record); + return std::make_pair(ptr->mId, ptr); } std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record) { - /* - /// \todo See function above. - std::ostringstream stream; - stream << "$dynamic" << mNextDynamicRecord++; - - const ESM::Spell *created = - &mStore.spells.list.insert (std::make_pair (stream.str(), record)).first->second; - - mStore.all.insert (std::make_pair (stream.str(), ESM::REC_SPEL)); - - return std::make_pair (stream.str(), created); - */ - std::string id = ""; - const ESM::Spell *ptr = 0; - return std::make_pair(id, ptr); + const ESM::Spell *ptr = mStore.insert(record); + return std::make_pair(ptr->mId, ptr); } const ESM::Cell *World::createRecord (const ESM::Cell& record) { - /* - if (record.mData.mFlags & ESM::Cell::Interior) - { - if (mStore.cells.searchInt (record.mName)) - throw std::runtime_error ("failed creating interior cell"); - - ESM::Cell *cell = new ESM::Cell (record); - mStore.cells.intCells.insert (std::make_pair (record.mName, cell)); - return cell; - } - else - { - if (mStore.cells.searchExt (record.mData.mX, record.mData.mY)) - throw std::runtime_error ("failed creating exterior cell"); - - ESM::Cell *cell = new ESM::Cell (record); - mStore.cells.extCells.insert ( - std::make_pair (std::make_pair (record.mData.mX, record.mData.mY), cell)); - return cell; - } - */ - return 0; + return mStore.insert(record); } void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 68a5ec142f..e6e01a0f98 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -60,7 +60,6 @@ namespace MWWorld MWWorld::Globals *mGlobalVariables; MWWorld::PhysicsSystem *mPhysics; bool mSky; - int mNextDynamicRecord; Cells mCells; From 83f5b1df81753f7dfdb1b50296c404734effa45b Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 17:58:49 +0400 Subject: [PATCH 153/255] change to static --> dynamic search order --- apps/openmw/mwworld/store.hpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 1adc2677eb..552f6d7606 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -107,17 +107,18 @@ namespace MWWorld T item; item.mId = StringUtils::lowerCase(id); - typename Dynamic::const_iterator dit = mDynamic.find(item.mId); - if (dit != mDynamic.end()) { - return &dit->second; - } - typename std::vector<T>::const_iterator it = std::lower_bound(mStatic.begin(), mStatic.end(), item, RecordCmp()); if (it != mStatic.end() && it->mId == item.mId) { return &(*it); } + + typename Dynamic::const_iterator dit = mDynamic.find(item.mId); + if (dit != mDynamic.end()) { + return &dit->second; + } + return 0; } @@ -388,17 +389,18 @@ namespace MWWorld ESM::Cell cell; cell.mName = StringUtils::lowerCase(id); - DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName); - if (dit != mDynamicInt.end()) { - return &dit->second; - } - std::vector<ESM::Cell>::const_iterator it = std::lower_bound(mInt.begin(), mInt.end(), cell, RecordCmp()); if (it != mInt.end() && StringUtils::ciEqual(it->mName, id)) { return &(*it); } + + DynamicInt::const_iterator dit = mDynamicInt.find(cell.mName); + if (dit != mDynamicInt.end()) { + return &dit->second; + } + return 0; } @@ -406,18 +408,19 @@ namespace MWWorld ESM::Cell cell; cell.mData.mX = x, cell.mData.mY = y; - std::pair<int, int> key(x, y); - DynamicExt::const_iterator dit = mDynamicExt.find(key); - if (dit != mDynamicExt.end()) { - return &dit->second; - } - std::vector<ESM::Cell>::const_iterator it = std::lower_bound(mExt.begin(), mExt.end(), cell, ExtCmp()); if (it != mExt.end() && it->mData.mX == x && it->mData.mY == y) { return &(*it); } + + std::pair<int, int> key(x, y); + DynamicExt::const_iterator dit = mDynamicExt.find(key); + if (dit != mDynamicExt.end()) { + return &dit->second; + } + return 0; } From 58b7927a36c45905365fc6054a7f535c6f02991c Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Tue, 6 Nov 2012 18:17:32 +0400 Subject: [PATCH 154/255] move 'player' record to dynamic --- apps/openmw/mwworld/esmstore.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index a69a8fde72..d0f00fa3a1 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -95,6 +95,16 @@ void ESMStore::setUp() mSkills.setUp(); mMagicEffects.setUp(); mAttributes.setUp(); + + ESM::NPC item; + item.mId = "player"; + + std::vector<ESM::NPC>::iterator pIt = + std::lower_bound(mNpcs.mStatic.begin(), mNpcs.mStatic.end(), item, RecordCmp()); + assert(pIt != mNpcs.mStatic.end() && pIt->mId == "player"); + + mNpcs.insert(*pIt); + mNpcs.mStatic.erase(pIt); } } // end namespace From 21e0cde914c7d5c7082894101fe5994840fcc741 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 6 Nov 2012 15:26:51 +0100 Subject: [PATCH 155/255] changed OIS includes since OIS_INCLUDE_DIR is already an include directory --- apps/openmw/mwinput/inputmanagerimp.cpp | 2 +- apps/openmw/mwinput/inputmanagerimp.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index c3e1314402..af30c9b04b 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -9,7 +9,7 @@ #include <boost/lexical_cast.hpp> -#include <OIS/OISInputManager.h> +#include <OISInputManager.h> #include <MyGUI_InputManager.h> #include <MyGUI_RenderManager.h> diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 5e6169f689..718d6b76f2 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -42,8 +42,8 @@ namespace OIS class InputManager; } -#include <OIS/OISKeyboard.h> -#include <OIS/OISMouse.h> +#include <OISKeyboard.h> +#include <OISMouse.h> #include <extern/oics/ICSChannelListener.h> #include <extern/oics/ICSInputControlSystem.h> From fb3ac6ad4ad4a3ace4af029a55e9f98548d56d4e Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 6 Nov 2012 19:08:15 +0100 Subject: [PATCH 156/255] no submodule --- .gitmodules | 4 +--- extern/shiny | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 160000 extern/shiny diff --git a/.gitmodules b/.gitmodules index d2a4cf0d31..8b13789179 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1 @@ -[submodule "extern/shiny"] - path = extern/shiny - url = git://github.com/scrawl/shiny.git + diff --git a/extern/shiny b/extern/shiny deleted file mode 160000 index f17c4ebab0..0000000000 --- a/extern/shiny +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f17c4ebab0e7a1f3bbb25fd9b3dbef2bd742536a From 7b35b828337ed4e07826c944826c265904799c02 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 6 Nov 2012 19:09:44 +0100 Subject: [PATCH 157/255] adding shiny --- extern/shiny/CMakeLists.txt | 72 + extern/shiny/Docs/Configurations.dox | 32 + extern/shiny/Docs/Doxyfile | 1826 ++++ extern/shiny/Docs/GettingStarted.dox | 65 + extern/shiny/Docs/Lod.dox | 49 + extern/shiny/Docs/Macros.dox | 270 + extern/shiny/Docs/Mainpage.dox | 13 + extern/shiny/Docs/Materials.dox | 128 + extern/shiny/Extra/core.h | 168 + extern/shiny/License.txt | 9 + extern/shiny/Main/Factory.cpp | 583 ++ extern/shiny/Main/Factory.hpp | 207 + extern/shiny/Main/Language.hpp | 16 + extern/shiny/Main/MaterialInstance.cpp | 218 + extern/shiny/Main/MaterialInstance.hpp | 104 + extern/shiny/Main/MaterialInstancePass.cpp | 16 + extern/shiny/Main/MaterialInstancePass.hpp | 29 + .../Main/MaterialInstanceTextureUnit.cpp | 14 + .../Main/MaterialInstanceTextureUnit.hpp | 26 + extern/shiny/Main/Platform.cpp | 94 + extern/shiny/Main/Platform.hpp | 145 + extern/shiny/Main/Preprocessor.cpp | 99 + extern/shiny/Main/Preprocessor.hpp | 69 + extern/shiny/Main/PropertyBase.cpp | 268 + extern/shiny/Main/PropertyBase.hpp | 235 + extern/shiny/Main/ScriptLoader.cpp | 401 + extern/shiny/Main/ScriptLoader.hpp | 134 + extern/shiny/Main/ShaderInstance.cpp | 707 ++ extern/shiny/Main/ShaderInstance.hpp | 71 + extern/shiny/Main/ShaderSet.cpp | 172 + extern/shiny/Main/ShaderSet.hpp | 71 + .../shiny/Platforms/Ogre/OgreGpuProgram.cpp | 70 + .../shiny/Platforms/Ogre/OgreGpuProgram.hpp | 31 + extern/shiny/Platforms/Ogre/OgreMaterial.cpp | 99 + extern/shiny/Platforms/Ogre/OgreMaterial.hpp | 38 + .../Platforms/Ogre/OgreMaterialSerializer.cpp | 67 + .../Platforms/Ogre/OgreMaterialSerializer.hpp | 29 + extern/shiny/Platforms/Ogre/OgrePass.cpp | 128 + extern/shiny/Platforms/Ogre/OgrePass.hpp | 35 + extern/shiny/Platforms/Ogre/OgrePlatform.cpp | 174 + extern/shiny/Platforms/Ogre/OgrePlatform.hpp | 72 + .../Platforms/Ogre/OgreTextureUnitState.cpp | 40 + .../Platforms/Ogre/OgreTextureUnitState.hpp | 27 + extern/shiny/Preprocessor/aq.cpp | 236 + extern/shiny/Preprocessor/cpp_re.cpp | 442 + extern/shiny/Preprocessor/cpp_re.inc | 9044 +++++++++++++++++ .../instantiate_cpp_exprgrammar.cpp | 52 + .../Preprocessor/instantiate_cpp_grammar.cpp | 56 + .../instantiate_cpp_literalgrs.cpp | 56 + .../instantiate_defined_grammar.cpp | 52 + .../instantiate_predef_macros.cpp | 52 + .../Preprocessor/instantiate_re2c_lexer.cpp | 65 + .../instantiate_re2c_lexer_str.cpp | 64 + extern/shiny/Preprocessor/token_ids.cpp | 447 + extern/shiny/Readme.txt | 33 + 55 files changed, 17720 insertions(+) create mode 100644 extern/shiny/CMakeLists.txt create mode 100644 extern/shiny/Docs/Configurations.dox create mode 100644 extern/shiny/Docs/Doxyfile create mode 100644 extern/shiny/Docs/GettingStarted.dox create mode 100644 extern/shiny/Docs/Lod.dox create mode 100644 extern/shiny/Docs/Macros.dox create mode 100644 extern/shiny/Docs/Mainpage.dox create mode 100644 extern/shiny/Docs/Materials.dox create mode 100644 extern/shiny/Extra/core.h create mode 100644 extern/shiny/License.txt create mode 100644 extern/shiny/Main/Factory.cpp create mode 100644 extern/shiny/Main/Factory.hpp create mode 100644 extern/shiny/Main/Language.hpp create mode 100644 extern/shiny/Main/MaterialInstance.cpp create mode 100644 extern/shiny/Main/MaterialInstance.hpp create mode 100644 extern/shiny/Main/MaterialInstancePass.cpp create mode 100644 extern/shiny/Main/MaterialInstancePass.hpp create mode 100644 extern/shiny/Main/MaterialInstanceTextureUnit.cpp create mode 100644 extern/shiny/Main/MaterialInstanceTextureUnit.hpp create mode 100644 extern/shiny/Main/Platform.cpp create mode 100644 extern/shiny/Main/Platform.hpp create mode 100644 extern/shiny/Main/Preprocessor.cpp create mode 100644 extern/shiny/Main/Preprocessor.hpp create mode 100644 extern/shiny/Main/PropertyBase.cpp create mode 100644 extern/shiny/Main/PropertyBase.hpp create mode 100644 extern/shiny/Main/ScriptLoader.cpp create mode 100644 extern/shiny/Main/ScriptLoader.hpp create mode 100644 extern/shiny/Main/ShaderInstance.cpp create mode 100644 extern/shiny/Main/ShaderInstance.hpp create mode 100644 extern/shiny/Main/ShaderSet.cpp create mode 100644 extern/shiny/Main/ShaderSet.hpp create mode 100644 extern/shiny/Platforms/Ogre/OgreGpuProgram.cpp create mode 100644 extern/shiny/Platforms/Ogre/OgreGpuProgram.hpp create mode 100644 extern/shiny/Platforms/Ogre/OgreMaterial.cpp create mode 100644 extern/shiny/Platforms/Ogre/OgreMaterial.hpp create mode 100644 extern/shiny/Platforms/Ogre/OgreMaterialSerializer.cpp create mode 100644 extern/shiny/Platforms/Ogre/OgreMaterialSerializer.hpp create mode 100644 extern/shiny/Platforms/Ogre/OgrePass.cpp create mode 100644 extern/shiny/Platforms/Ogre/OgrePass.hpp create mode 100644 extern/shiny/Platforms/Ogre/OgrePlatform.cpp create mode 100644 extern/shiny/Platforms/Ogre/OgrePlatform.hpp create mode 100644 extern/shiny/Platforms/Ogre/OgreTextureUnitState.cpp create mode 100644 extern/shiny/Platforms/Ogre/OgreTextureUnitState.hpp create mode 100644 extern/shiny/Preprocessor/aq.cpp create mode 100644 extern/shiny/Preprocessor/cpp_re.cpp create mode 100644 extern/shiny/Preprocessor/cpp_re.inc create mode 100644 extern/shiny/Preprocessor/instantiate_cpp_exprgrammar.cpp create mode 100644 extern/shiny/Preprocessor/instantiate_cpp_grammar.cpp create mode 100644 extern/shiny/Preprocessor/instantiate_cpp_literalgrs.cpp create mode 100644 extern/shiny/Preprocessor/instantiate_defined_grammar.cpp create mode 100644 extern/shiny/Preprocessor/instantiate_predef_macros.cpp create mode 100644 extern/shiny/Preprocessor/instantiate_re2c_lexer.cpp create mode 100644 extern/shiny/Preprocessor/instantiate_re2c_lexer_str.cpp create mode 100644 extern/shiny/Preprocessor/token_ids.cpp create mode 100644 extern/shiny/Readme.txt diff --git a/extern/shiny/CMakeLists.txt b/extern/shiny/CMakeLists.txt new file mode 100644 index 0000000000..c27850ed65 --- /dev/null +++ b/extern/shiny/CMakeLists.txt @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 2.8) + +# This is NOT intended as a stand-alone build system! Instead, you should include this from the main CMakeLists of your project. +# Make sure to link against Ogre and boost::filesystem. + +option(SHINY_BUILD_OGRE_PLATFORM "build the Ogre platform" ON) + +set(SHINY_LIBRARY "shiny") +set(SHINY_OGREPLATFORM_LIBRARY "shiny.OgrePlatform") + +# Sources +file(GLOB SOURCE_FILES Main/*.cpp ) + +set(SOURCE_FILES + Main/Factory.cpp + Main/MaterialInstance.cpp + Main/MaterialInstancePass.cpp + Main/MaterialInstanceTextureUnit.cpp + Main/Platform.cpp + Main/Preprocessor.cpp + Main/PropertyBase.cpp + Main/ScriptLoader.cpp + Main/ShaderInstance.cpp + Main/ShaderSet.cpp +) + +# In Debug mode, write the shader sources to the current directory +if (DEFINED CMAKE_BUILD_TYPE) + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-DSHINY_WRITE_SHADER_DEBUG) + endif() +endif() + +if (DEFINED SHINY_USE_WAVE_SYSTEM_INSTALL) + # use system install +else() + list(APPEND SOURCE_FILES + Preprocessor/aq.cpp + Preprocessor/cpp_re.cpp + Preprocessor/instantiate_cpp_literalgrs.cpp + Preprocessor/instantiate_cpp_exprgrammar.cpp + Preprocessor/instantiate_cpp_grammar.cpp + Preprocessor/instantiate_defined_grammar.cpp + Preprocessor/instantiate_predef_macros.cpp + Preprocessor/instantiate_re2c_lexer.cpp + Preprocessor/instantiate_re2c_lexer_str.cpp + Preprocessor/token_ids.cpp + ) + + # Don't use thread-safe boost::wave. Results in a huge speed-up for the preprocessor. + add_definitions(-DBOOST_WAVE_SUPPORT_THREADING=0) +endif() + +set(OGRE_PLATFORM_SOURCE_FILES + Platforms/Ogre/OgreGpuProgram.cpp + Platforms/Ogre/OgreMaterial.cpp + Platforms/Ogre/OgreMaterialSerializer.cpp + Platforms/Ogre/OgrePass.cpp + Platforms/Ogre/OgrePlatform.cpp + Platforms/Ogre/OgreTextureUnitState.cpp +) + +file(GLOB OGRE_PLATFORM_SOURCE_FILES Platforms/Ogre/*.cpp) + +add_library(${SHINY_LIBRARY} STATIC ${SOURCE_FILES}) + +if (SHINY_BUILD_OGRE_PLATFORM) + add_library(${SHINY_OGREPLATFORM_LIBRARY} STATIC ${OGRE_PLATFORM_SOURCE_FILES}) +endif() + + +link_directories(${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extern/shiny/Docs/Configurations.dox b/extern/shiny/Docs/Configurations.dox new file mode 100644 index 0000000000..affd914237 --- /dev/null +++ b/extern/shiny/Docs/Configurations.dox @@ -0,0 +1,32 @@ +/*! + + \page configurations Configurations + + A common task in shader development is to provide a different set of simpler shaders for all your materials. Some examples: + - When rendering cubic or planar reflection maps in real-time, you will want to disable shadows. + - For an in-game minimap render target, you don't want to have fog. + + For this task, the library provides a \a Configuration concept. + + A Configuration is a set of properties that can override global settings, as long as this Configuration is active. + + Here's an example. Say you have a global setting with the name 'shadows' that controls if your materials receive shadows. + + Now, lets create a configuration for our reflection render targets that disables shadows for all materials. Paste the following in a new file with the extension '.configuration': + + \code + configuration reflection_targets + { + shadows false + } + \endcode + + \note You may also create configurations using sh::Factory::registerConfiguration. + + The active Configuration is controlled by the active material scheme in Ogre. So, in order to use the configuration "reflection_targets" for your reflection renders, simply call + \code + viewport->setMaterialScheme ("reflection_targets"); + \endcode + on the Ogre viewport of your reflection render! + +*/ diff --git a/extern/shiny/Docs/Doxyfile b/extern/shiny/Docs/Doxyfile new file mode 100644 index 0000000000..3564c45f67 --- /dev/null +++ b/extern/shiny/Docs/Doxyfile @@ -0,0 +1,1826 @@ +# Doxyfile 1.8.1.1 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project +# +# All text after a hash (#) is considered a comment and will be ignored +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" ") + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. + +PROJECT_NAME = shiny + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = /home/scrawl/sh_doxy/generated + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = NO + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = YES + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = YES + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 8 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = + +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = NO + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +SYMBOL_CACHE_SIZE = 0 + +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = YES + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = NO + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = NO + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = YES + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = YES + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command <command> <input-file>, where <command> is the value of +# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. To create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = + +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = NO + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = NO + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = ../ + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should be +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command <filter> <input-file>, where <filter> +# is the value of the INPUT_FILTER tag, and <input-file> is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = NO + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C, C++ and Fortran comments will always remain visible. + +STRIP_CODE_COMMENTS = YES + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = NO + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = NO + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = YES + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = YES + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is advised to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when +# changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# style sheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the style sheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. + +HTML_DYNAMIC_SECTIONS = NO + +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters"> +# Qt Help Project / Custom Filters</a>. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes"> +# Qt Help Project / Filter Attributes</a>. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. + +DISABLE_INDEX = NO + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. + +GENERATE_TREEVIEW = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you may also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. + +MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest + +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = YES + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = YES + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4 + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load style sheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. This is useful +# if you want to understand what is going on. On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = NO + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = NO + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = NO + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. + +DOT_FONTNAME = Helvetica + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = NO + +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = YES + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = YES + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = NO + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = YES + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). + +DOT_IMAGE_FORMAT = png + +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 50 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 0 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = NO + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES diff --git a/extern/shiny/Docs/GettingStarted.dox b/extern/shiny/Docs/GettingStarted.dox new file mode 100644 index 0000000000..b9cf58e23a --- /dev/null +++ b/extern/shiny/Docs/GettingStarted.dox @@ -0,0 +1,65 @@ +/*! + \page getting-started Getting started + + \section download Download the source + + \code + git clone git@github.com:scrawl/shiny.git + \endcode + + \section building Build the source + + The source files you want to build are: + - Main/*.cpp + - Preprocessor/*.cpp (unless you are using the system install of boost::wave, more below) + - Platforms/Ogre/*.cpp + + You can either build the sources as a static library, or simply add the sources to the source tree of your project. + + If you use CMake, you might find the included CMakeLists.txt useful. It builds static libraries with the names "shiny" and "shiny.OgrePlatform". + + \note The CMakeLists.txt is not intended as a stand-alone build system! Instead, you should include this from the main CMakeLists of your project. + + Make sure to link against OGRE and the boost filesystem library. + + If your boost version is older than 1.49, you must set the SHINY_USE_WAVE_SYSTEM_INSTALL variable and additionally link against the boost wave library. + + \code + set(SHINY_USE_WAVE_SYSTEM_INSTALL "TRUE") + \endcode + + \section code Basic initialisation code + + Add the following code to your application: + + \code{cpp} + + #include <shiny/Main/Factory.hpp> + #include <shiny/Platforms/OgrePlatform/OgrePlatform.hpp> + + .... + + sh::OgrePlatform* platform = new sh::OgrePlatform( + "General", // OGRE Resource group to use for creating materials. + myApplication.getDataPath() + "/" + "materials" // Path to look for materials and shaders. NOTE: This does NOT use the Ogre resource system, so you have to specify an absolute path. + ); + + sh::Factory* factory = new sh::Factory(platform); + + // Set a language. Valid options: CG, HLSL, GLSL + factory->setCurrentLanguage(sh::Language_GLSL); + + factory->loadAllFiles(); + + .... + your application runs here + .... + + // don't forget to delete on exit + delete factory; + + \endcode + + That's it! Now you can start defining materials. Refer to the page \ref defining-materials-shaders . + +*/ diff --git a/extern/shiny/Docs/Lod.dox b/extern/shiny/Docs/Lod.dox new file mode 100644 index 0000000000..37d004638e --- /dev/null +++ b/extern/shiny/Docs/Lod.dox @@ -0,0 +1,49 @@ +/*! + + \page lod Material LOD + + \section howitworks How it works + + When Ogre requests a technique for a specific LOD index, the Factory selects the appropriate LOD configuration which then temporarily overrides the global settings in the shaders. We can use this to disable shader features one by one at a lower LOD, resulting in simpler and faster techniques for distant objects. + + \section howtouseit How to use it + + - Create a file with the extension '.lod'. There you can specify shader features to disable at a specific LOD level. Higher LOD index refers to a lower LOD. Example contents: + + \code + lod_configuration 1 + { + specular_mapping false + } + + lod_configuration 2 + { + specular_mapping false + normal_mapping false + } + + lod_configuration 3 + { + terrain_composite_map true + specular_mapping false + normal_mapping false + } + \endcode + + \note You can also add LOD configurations by calling \a sh::Factory::registerLodConfiguration. + + \note Do not use an index of 0. LOD 0 refers to the highest LOD, and you will never want to disable features at the highest LOD level. + + + - In your materials, specify the distances at which a lower LOD kicks in. Note that the actual distance might also be affected by the viewport and current entity LOD bias. In this example, the first LOD level (lod index 1) would normally be applied at a distance of 100 units, the next after 300, and the last after 1000 units. + + \code + material sample_material + { + lod_values 100 300 1000 + + ... your passes, texture units etc ... + } + \endcode + +*/ diff --git a/extern/shiny/Docs/Macros.dox b/extern/shiny/Docs/Macros.dox new file mode 100644 index 0000000000..0578c447f3 --- /dev/null +++ b/extern/shiny/Docs/Macros.dox @@ -0,0 +1,270 @@ +/*! + \page macros Shader Macros + + \tableofcontents + + \section Shader Language + + These macros are automatically defined, depending on the shader language that has been set by the application using sh::Factory::setCurrentLanguage. + + - SH_GLSL + - SH_HLSL + - SH_CG + + <B>Example:</B> + + \code + #if SH_GLSL == 1 + // glsl porting code + #endif + + #if SH_CG == 1 || SH_HLSL == 1 + // cg / hlsl porting code (similiar syntax) + #endif + \endcode + + \note It is encouraged to use the shipped porting header (extra/core.h) by #include-ing it in your shaders. If you do that, you should not have to use the above macros directly. + + \section vertex-fragment Vertex / fragment shader + + These macros are automatically defined, depending on the type of shader that is currently being compiled. + + - SH_VERTEX_SHADER + - SH_FRAGMENT_SHADER + + If you use the same source file for both vertex and fragment shader, then it is advised to use these macros for blending out the unused source. This will reduce your compile time. + + \section passthrough Vertex -> Fragment passthrough + + In shader development, a common task is to pass variables from the vertex to the fragment shader. This is no problem if you have a deterministic shader source (i.e. no #ifdefs). + + However, as soon as you begin to have lots of permutations of the same shader source, a problem arises. All current GPUs have a limit of 8 vertex to fragment passthroughs (with 4 components each, for example a float4). + + A common optimization is to put several individual float values together in a float4 (so-called "Packing"). But if your shader has lots of permutations and the passthrough elements you actually need are not known beforehand, it can be very tedious to pack manually. With the following macros, packing can become easier. + + \subsection shAllocatePassthrough shAllocatePassthrough + + <B>Usage:</B> \@shAllocatePassthrough(num_components, name) + + <B>Example:</B> + \code + #if FRAGMENT_NEED_DEPTH + @shAllocatePassthrough(1, depth) + #endif + \endcode + + This is the first thing you should do before using any of the macros below. + + \subsection shPassthroughVertexOutputs shPassthroughVertexOutputs + + <B>Usage:</B> \@shPassthroughVertexOutputs + + Use this in the inputs/outputs section of your vertex shader, in order to declare all the outputs that are needed for packing the variables that you want passed to the fragment. + + \subsection shPassthroughFragmentInputs shPassthroughFragmentInputs + + <B>Usage:</B> \@shPassthroughFragmentInputs + + Use this in the inputs/outputs section of your fragment shader, in order to declare all the inputs that are needed for receiving the variables that you want passed to the fragment. + + \subsection shPassthroughAssign shPassthroughAssign + + <B>Usage:</B> \@shPassthroughAssign(name, value) + + Use this in the vertex shader for assigning a value to the variable you want passed to the fragment. + + <B>Example:</B> + \code + #if FRAGMENT_NEED_DEPTH + @shPassthroughAssign(depth, shOutputPosition.z); + #endif + + \endcode + + \subsection shPassthroughReceive shPassthroughReceive + + <B>Usage:</B> \@shPassthroughReceive(name) + + Use this in the fragment shader to receive the passed value. + + <B>Example:</B> + + \code + #if FRAGMENT_NEED_DEPTH + float depth = @shPassthroughReceive(depth); + #endif + \endcode + + \section texUnits Texture units + + \subsection shUseSampler shUseSampler + + <B>Usage:</B> \@shUseSampler(samplerName) + + Requests the texture unit with name \a samplerName to be available for use in this pass. + + Why is this necessary? If you have a derived material that does not use all of the texture units that its parent defines (for example, if an optional asset such as a normal map is not available), there would be no way to know which texture units are actually needed and which can be skipped in the creation process (those that are never referenced in the shader). + + \section properties Property retrieval / binding + + \subsection shUniformProperty shUniformProperty + + <B>Usage:</B> \@shUniformProperty<4f|3f|2f|1f|int> (uniformName, property) + + Binds the value of \a property (from the shader_properties of the pass this shader belongs to) to the uniform with name \a uniformName. + + The following variants are available, depending on the type of your uniform variable: + - \@shUniformProperty4f + - \@shUniformProperty3f + - \@shUniformProperty2f + - \@shUniformProperty1f + - \@shUniformPropertyInt + + <B>Example:</B> \@shUniformProperty1f (uFresnelScale, fresnelScale) + + \subsection shPropertyBool shPropertyBool + + Retrieve a boolean property of the pass that this shader belongs to, gets replaced with either 0 or 1. + + <B>Usage:</B> \@shPropertyBool(propertyName) + + <B>Example:</B> + \code + #if @shPropertyBool(has_normal_map) + ... + #endif + \endcode + + \subsection shPropertyNotBool shPropertyNotBool + + Same as shPropertyBool, but inverts the result (i.e. when shPropertyBool would return 0, this returns 1 and vice versa) + + \subsection shPropertyString shPropertyString + + Retrieve a string property of the pass that this shader belongs to + + <B>Usage:</B> \@shPropertyString(propertyName) + + \subsection shPropertyEqual shPropertyEqual + + Check if the value of a property equals a specific value, gets replaced with either 0 or 1. This is useful because the preprocessor cannot compare strings, only numbers. + + <B>Usage:</B> \@shPropertyEqual(propertyName, value) + + <B>Example:</B> + \code + #if @shPropertyEqual(lighting_mode, phong) + ... + #endif + \endcode + + \section globalSettings Global settings + + \subsection shGlobalSettingBool shGlobalSettingBool + + Retrieves the boolean value of a specific global setting, gets replaced with either 0 or 1. The value can be set using sh::Factory::setGlobalSetting. + + <B>Usage:</B> \@shGlobalSettingBool(settingName) + + \subsection shGlobalSettingEqual shGlobalSettingEqual + + Check if the value of a global setting equals a specific value, gets replaced with either 0 or 1. This is useful because the preprocessor cannot compare strings, only numbers. + + <B>Usage:</B> \@shGlobalSettingEqual(settingName, value) + + \subsection shGlobalSettingString shGlobalSettingString + + Gets replaced with the current value of a given global setting. The value can be set using sh::Factory::setGlobalSetting. + + <B>Usage:</B> \@shGlobalSettingString(settingName) + + \section sharedParams Shared parameters + + \subsection shSharedParameter shSharedParameter + + Allows you to bind a custom value to a uniform parameter. + + <B>Usage</B>: \@shSharedParameter(sharedParameterName) + + <B>Example</B>: \@shSharedParameter(pssmSplitPoints) - now the uniform parameter 'pssmSplitPoints' can be altered in all shaders that use it by executing sh::Factory::setSharedParameter("pssmSplitPoints", value) + + \note You may use the same shared parameter in as many shaders as you want. But don't forget to add the \@shSharedParameter macro to every shader that uses this shared parameter. + + \section autoconstants Auto constants + + \subsection shAutoConstant shAutoConstant + + <B>Usage:</B> \@shAutoConstant(uniformName, autoConstantName, [extraData]) + + <B>Example</B>: \@shAutoConstant(uModelViewMatrix, worldviewproj_matrix) + + <B>Example</B>: \@shAutoConstant(uLightPosition4, light_position, 4) + + Binds auto constant with name \a autoConstantName to the uniform \a uniformName. Optionally, you may specify extra data (for example the light index), as required by some auto constants. + + The auto constant names are the same as Ogre's. Read the section "3.1.9 Using Vertex/Geometry/Fragment Programs in a Pass" of the Ogre manual for a list of all auto constant names. + + \section misc Misc + + \subsection shForeach shForeach + + <B>Usage:</B> \@shForeach(n) + + Repeats the content of this foreach block \a n times. The end of the block is marked via \@shEndForeach, and the current iteration number can be retrieved via \@shIterator. + + \note Nested foreach blocks are currently \a not supported. + + \note For technical reasons, you can only use constant numbers, properties (\@shPropertyString) or global settings (\@shGlobalSettingString) as \a n parameter. + + <B>Example:</B> + + \code + @shForeach(3) + this is iteration number @shIterator + @shEndForeach + + Gets replaced with: + + this is iteration number 0 + this is iteration number 1 + this is iteration number 2 + \endcode + + Optionally, you can pass a constant offset to \@shIterator. Example: + + \code + @shForeach(3) + this is iteration number @shIterator(7) + @shEndForeach + + Gets replaced with: + + this is iteration number 7 + this is iteration number 8 + this is iteration number 9 + \endcode + + \subsection shCounter shCounter + + Gets replaced after the preprocessing step with the number that equals the n-th occurence of counters of the same ID. + + <B>Usage:</B> \@shCounter(ID) + + <B>Example</B>: + \code + @shCounter(0) + @shCounter(0) + @shCounter(1) + @shCounter(0) + \endcode + + Gets replaced with: + + \code + 0 + 1 + 0 + 2 + \endcode + +*/ diff --git a/extern/shiny/Docs/Mainpage.dox b/extern/shiny/Docs/Mainpage.dox new file mode 100644 index 0000000000..fb8f596dc0 --- /dev/null +++ b/extern/shiny/Docs/Mainpage.dox @@ -0,0 +1,13 @@ +/*! + + \mainpage + + - \ref getting-started + - \ref defining-materials-shaders + - \ref macros + - \ref configurations + - \ref lod + + - sh::Factory - the main interface class + +*/ diff --git a/extern/shiny/Docs/Materials.dox b/extern/shiny/Docs/Materials.dox new file mode 100644 index 0000000000..2dae60560d --- /dev/null +++ b/extern/shiny/Docs/Materials.dox @@ -0,0 +1,128 @@ +/*! + + \page defining-materials-shaders Defining materials and shaders + + \section first-material Your first material + + Create a file called "myFirstMaterial.mat" and place it in the path you have used in your initialisation code (see \ref getting-started). Paste the following: + + \code + + material my_first_material + { + diffuse 1.0 1.0 1.0 1.0 + specular 0.4 0.4 0.4 32 + ambient 1.0 1.0 1.0 + emissive 0.0 0.0 0.0 + diffuseMap black.png + + pass + { + diffuse $diffuse + specular $specular + ambient $ambient + emissive $emissive + + texture_unit diffuseMap + { + texture $diffuseMap + create_in_ffp true // use this texture unit for fixed function pipeline + } + } + } + + material material1 + { + parent my_first_material + diffuseMap texture1.png + } + + material material2 + { + parent my_first_material + diffuseMap texture2.png + } + + \endcode + + \section first-shader The first shader + + Change the 'pass' section to include some shaders: + + \code + pass + { + vertex_program my_first_shader_vertex + fragment_program my_first_shader_fragment + ... + } + \endcode + + \note This does \a not refer to a single shader with a fixed source code, but in fact will automatically create a new \a instance of this shader (if necessary), which can have its own uniform variables, compile-time macros and much more! + + Next, we're going to define our shaders. Paste this in a new file called 'myfirstshader.shaderset' + + \code + shader_set my_first_shader_vertex + { + source example.shader + type vertex + profiles_cg vs_2_0 arbvp1 + profiles_hlsl vs_2_0 + } + + shader_set my_first_shader_fragment + { + source example.shader + type fragment + profiles_cg ps_2_x ps_2_0 ps arbfp1 + profiles_hlsl ps_2_0 + } + \endcode + + Some notes: + - There is no entry_point property because the entry point is always \a main. + - Both profiles_cg and profiles_hlsl are a list of shader profiles. The first profile that is supported is automatically picked. GLSL does not have shader profiles. + + Now, let's get into writing our shader! As you can guess from above, the filename should be 'example.shader' + + \code + #include "core.h" + + #ifdef SH_VERTEX_SHADER + + SH_BEGIN_PROGRAM + shUniform(float4x4, wvp) @shAutoConstant(wvp, worldviewproj_matrix) + shInput(float2, uv0) + shOutput(float2, UV) + SH_START_PROGRAM + { + shOutputPosition = shMatrixMult(wvp, shInputPosition); + UV = uv0; + } + + #else + + SH_BEGIN_PROGRAM + // NOTE: It is important that the sampler name here (diffuseMap) matches + // the name of the texture unit in the material. This is necessary because the system + // skips texture units that are never "referenced" in the shader. This can be the case + // when your base material has optional assets (for example a normal map) that are not + // used by some derived materials. + shSampler2D(diffuseMap) + shInput(float2, UV) + SH_START_PROGRAM + { + shOutputColour(0) = shSample(diffuseMap, UV); + } + + #endif + + \endcode + + There you have it! This shader will compile in several languages thanks to the porting defines in "core.h". If you need more defines, feel free to add them and don't forget to send them to me! + + For a full list of macros available when writing your shaders, refer to the page \ref macros + + In the future, some more in-depth shader examples might follow. +*/ diff --git a/extern/shiny/Extra/core.h b/extern/shiny/Extra/core.h new file mode 100644 index 0000000000..cba7167770 --- /dev/null +++ b/extern/shiny/Extra/core.h @@ -0,0 +1,168 @@ +#if SH_HLSL == 1 || SH_CG == 1 + + #define shTexture2D sampler2D + #define shSample(tex, coord) tex2D(tex, coord) + #define shCubicSample(tex, coord) texCUBE(tex, coord) + #define shLerp(a, b, t) lerp(a, b, t) + #define shSaturate(a) saturate(a) + + #define shSampler2D(name) , uniform sampler2D name : register(s@shCounter(0)) @shUseSampler(name) + + #define shSamplerCube(name) , uniform samplerCUBE name : register(s@shCounter(0)) @shUseSampler(name) + + #define shMatrixMult(m, v) mul(m, v) + + #define shUniform(type, name) , uniform type name + + #define shTangentInput(type) , in type tangent : TANGENT + #define shVertexInput(type, name) , in type name : TEXCOORD@shCounter(1) + #define shInput(type, name) , in type name : TEXCOORD@shCounter(1) + #define shOutput(type, name) , out type name : TEXCOORD@shCounter(2) + + #define shNormalInput(type) , in type normal : NORMAL + + #define shColourInput(type) , in type colour : COLOR + + #ifdef SH_VERTEX_SHADER + + #define shOutputPosition oPosition + #define shInputPosition iPosition + + + #define SH_BEGIN_PROGRAM \ + void main( \ + float4 iPosition : POSITION \ + , out float4 oPosition : POSITION + + #define SH_START_PROGRAM \ + ) \ + + #endif + + #ifdef SH_FRAGMENT_SHADER + + #define shOutputColour(num) oColor##num + + #define shDeclareMrtOutput(num) , out float4 oColor##num : COLOR##num + + #define SH_BEGIN_PROGRAM \ + void main( \ + out float4 oColor0 : COLOR + + #define SH_START_PROGRAM \ + ) \ + + #endif + +#endif + +#if SH_GLSL == 1 + + @version 120 + + #define float2 vec2 + #define float3 vec3 + #define float4 vec4 + #define int2 ivec2 + #define int3 ivec3 + #define int4 ivec4 + #define shTexture2D sampler2D + #define shSample(tex, coord) texture2D(tex, coord) + #define shCubicSample(tex, coord) textureCube(tex, coord) + #define shLerp(a, b, t) mix(a, b, t) + #define shSaturate(a) clamp(a, 0.0, 1.0) + + #define shUniform(type, name) uniform type name; + + #define shSampler2D(name) uniform sampler2D name; @shUseSampler(name) + + #define shSamplerCube(name) uniform samplerCube name; @shUseSampler(name) + + #define shMatrixMult(m, v) (m * v) + + #define shOutputPosition gl_Position + + #define float4x4 mat4 + #define float3x3 mat3 + + // GLSL 1.3 + #if 0 + + // automatically recognized by ogre when the input name equals this + #define shInputPosition vertex + + #define shOutputColour(num) oColor##num + + #define shTangentInput(type) in type tangent; + #define shVertexInput(type, name) in type name; + #define shInput(type, name) in type name; + #define shOutput(type, name) out type name; + + // automatically recognized by ogre when the input name equals this + #define shNormalInput(type) in type normal; + #define shColourInput(type) in type colour; + + #ifdef SH_VERTEX_SHADER + + #define SH_BEGIN_PROGRAM \ + in float4 vertex; + #define SH_START_PROGRAM \ + void main(void) + + #endif + + #ifdef SH_FRAGMENT_SHADER + + #define shDeclareMrtOutput(num) out vec4 oColor##num; + + #define SH_BEGIN_PROGRAM \ + out float4 oColor0; + #define SH_START_PROGRAM \ + void main(void) + + + #endif + + #endif + + // GLSL 1.2 + + #if 1 + + // automatically recognized by ogre when the input name equals this + #define shInputPosition vertex + + #define shOutputColour(num) gl_FragData[num] + + #define shTangentInput(type) attribute type tangent; + #define shVertexInput(type, name) attribute type name; + #define shInput(type, name) varying type name; + #define shOutput(type, name) varying type name; + + // automatically recognized by ogre when the input name equals this + #define shNormalInput(type) attribute type normal; + #define shColourInput(type) attribute type colour; + + #ifdef SH_VERTEX_SHADER + + #define SH_BEGIN_PROGRAM \ + attribute vec4 vertex; + #define SH_START_PROGRAM \ + void main(void) + + #endif + + #ifdef SH_FRAGMENT_SHADER + + #define shDeclareMrtOutput(num) + + #define SH_BEGIN_PROGRAM + + #define SH_START_PROGRAM \ + void main(void) + + + #endif + + #endif +#endif diff --git a/extern/shiny/License.txt b/extern/shiny/License.txt new file mode 100644 index 0000000000..d89bcf3ad2 --- /dev/null +++ b/extern/shiny/License.txt @@ -0,0 +1,9 @@ +Copyright (c) 2012 <scrawl@baseoftrash.de> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + diff --git a/extern/shiny/Main/Factory.cpp b/extern/shiny/Main/Factory.cpp new file mode 100644 index 0000000000..678ee25c96 --- /dev/null +++ b/extern/shiny/Main/Factory.cpp @@ -0,0 +1,583 @@ +#include "Factory.hpp" + +#include <stdexcept> +#include <iostream> + +#include <boost/algorithm/string.hpp> +#include <boost/filesystem.hpp> +#include <boost/lexical_cast.hpp> + +#include "Platform.hpp" +#include "ScriptLoader.hpp" +#include "ShaderSet.hpp" +#include "MaterialInstanceTextureUnit.hpp" + +namespace sh +{ + Factory* Factory::sThis = 0; + + Factory& Factory::getInstance() + { + assert (sThis); + return *sThis; + } + + Factory* Factory::getInstancePtr() + { + return sThis; + } + + Factory::Factory (Platform* platform) + : mPlatform(platform) + , mShadersEnabled(true) + , mShaderDebugOutputEnabled(false) + , mCurrentLanguage(Language_None) + , mListener(NULL) + , mCurrentConfiguration(NULL) + , mCurrentLodConfiguration(NULL) + , mReadMicrocodeCache(false) + , mWriteMicrocodeCache(false) + , mReadSourceCache(false) + , mWriteSourceCache(false) + { + assert (!sThis); + sThis = this; + + mPlatform->setFactory(this); + } + + void Factory::loadAllFiles() + { + assert(mCurrentLanguage != Language_None); + + bool anyShaderDirty = false; + + if (boost::filesystem::exists (mPlatform->getCacheFolder () + "/lastModified.txt")) + { + std::ifstream file; + file.open(std::string(mPlatform->getCacheFolder () + "/lastModified.txt").c_str()); + + std::string line; + while (getline(file, line)) + { + std::string sourceFile = line; + + if (!getline(file, line)) + assert(0); + + int modified = boost::lexical_cast<int>(line); + + mShadersLastModified[sourceFile] = modified; + } + } + + // load configurations + { + ScriptLoader shaderSetLoader(".configuration"); + ScriptLoader::loadAllFiles (&shaderSetLoader, mPlatform->getBasePath()); + std::map <std::string, ScriptNode*> nodes = shaderSetLoader.getAllConfigScripts(); + for (std::map <std::string, ScriptNode*>::const_iterator it = nodes.begin(); + it != nodes.end(); ++it) + { + if (!(it->second->getName() == "configuration")) + { + std::cerr << "sh::Factory: Warning: Unsupported root node type \"" << it->second->getName() << "\" for file type .configuration" << std::endl; + break; + } + + PropertySetGet newConfiguration; + newConfiguration.setParent(&mGlobalSettings); + + std::vector<ScriptNode*> props = it->second->getChildren(); + for (std::vector<ScriptNode*>::const_iterator propIt = props.begin(); propIt != props.end(); ++propIt) + { + std::string name = (*propIt)->getName(); + std::string val = (*propIt)->getValue(); + + newConfiguration.setProperty (name, makeProperty(val)); + } + + mConfigurations[it->first] = newConfiguration; + } + } + + // load lod configurations + { + ScriptLoader lodLoader(".lod"); + ScriptLoader::loadAllFiles (&lodLoader, mPlatform->getBasePath()); + std::map <std::string, ScriptNode*> nodes = lodLoader.getAllConfigScripts(); + for (std::map <std::string, ScriptNode*>::const_iterator it = nodes.begin(); + it != nodes.end(); ++it) + { + if (!(it->second->getName() == "lod_configuration")) + { + std::cerr << "sh::Factory: Warning: Unsupported root node type \"" << it->second->getName() << "\" for file type .lod" << std::endl; + break; + } + + if (it->first == "0") + { + throw std::runtime_error("lod level 0 (max lod) can't have a configuration"); + } + + PropertySetGet newLod; + + std::vector<ScriptNode*> props = it->second->getChildren(); + for (std::vector<ScriptNode*>::const_iterator propIt = props.begin(); propIt != props.end(); ++propIt) + { + std::string name = (*propIt)->getName(); + std::string val = (*propIt)->getValue(); + + newLod.setProperty (name, makeProperty(val)); + } + + mLodConfigurations[boost::lexical_cast<int>(it->first)] = newLod; + } + } + + // load shader sets + { + ScriptLoader shaderSetLoader(".shaderset"); + ScriptLoader::loadAllFiles (&shaderSetLoader, mPlatform->getBasePath()); + std::map <std::string, ScriptNode*> nodes = shaderSetLoader.getAllConfigScripts(); + for (std::map <std::string, ScriptNode*>::const_iterator it = nodes.begin(); + it != nodes.end(); ++it) + { + if (!(it->second->getName() == "shader_set")) + { + std::cerr << "sh::Factory: Warning: Unsupported root node type \"" << it->second->getName() << "\" for file type .shaderset" << std::endl; + break; + } + + if (!it->second->findChild("profiles_cg")) + throw std::runtime_error ("missing \"profiles_cg\" field for \"" + it->first + "\""); + if (!it->second->findChild("profiles_hlsl")) + throw std::runtime_error ("missing \"profiles_hlsl\" field for \"" + it->first + "\""); + if (!it->second->findChild("source")) + throw std::runtime_error ("missing \"source\" field for \"" + it->first + "\""); + if (!it->second->findChild("type")) + throw std::runtime_error ("missing \"type\" field for \"" + it->first + "\""); + + std::vector<std::string> profiles_cg; + boost::split (profiles_cg, it->second->findChild("profiles_cg")->getValue(), boost::is_any_of(" ")); + std::string cg_profile; + for (std::vector<std::string>::iterator it2 = profiles_cg.begin(); it2 != profiles_cg.end(); ++it2) + { + if (mPlatform->isProfileSupported(*it2)) + { + cg_profile = *it2; + break; + } + } + + std::vector<std::string> profiles_hlsl; + boost::split (profiles_hlsl, it->second->findChild("profiles_hlsl")->getValue(), boost::is_any_of(" ")); + std::string hlsl_profile; + for (std::vector<std::string>::iterator it2 = profiles_hlsl.begin(); it2 != profiles_hlsl.end(); ++it2) + { + if (mPlatform->isProfileSupported(*it2)) + { + hlsl_profile = *it2; + break; + } + } + + std::string sourceFile = mPlatform->getBasePath() + "/" + it->second->findChild("source")->getValue(); + + ShaderSet newSet (it->second->findChild("type")->getValue(), cg_profile, hlsl_profile, + sourceFile, + mPlatform->getBasePath(), + it->first, + &mGlobalSettings); + + int lastModified = boost::filesystem::last_write_time (boost::filesystem::path(sourceFile)); + if (mShadersLastModified.find(sourceFile) != mShadersLastModified.end() + && mShadersLastModified[sourceFile] != lastModified) + { + newSet.markDirty (); + anyShaderDirty = true; + } + + mShadersLastModified[sourceFile] = lastModified; + + mShaderSets.insert(std::make_pair(it->first, newSet)); + } + } + + // load materials + { + ScriptLoader materialLoader(".mat"); + ScriptLoader::loadAllFiles (&materialLoader, mPlatform->getBasePath()); + + std::map <std::string, ScriptNode*> nodes = materialLoader.getAllConfigScripts(); + for (std::map <std::string, ScriptNode*>::const_iterator it = nodes.begin(); + it != nodes.end(); ++it) + { + if (!(it->second->getName() == "material")) + { + std::cerr << "sh::Factory: Warning: Unsupported root node type \"" << it->second->getName() << "\" for file type .mat" << std::endl; + break; + } + + MaterialInstance newInstance(it->first, this); + newInstance.create(mPlatform); + if (!mShadersEnabled) + newInstance.setShadersEnabled (false); + + newInstance.setSourceFile (it->second->m_fileName); + + std::vector<ScriptNode*> props = it->second->getChildren(); + for (std::vector<ScriptNode*>::const_iterator propIt = props.begin(); propIt != props.end(); ++propIt) + { + std::string name = (*propIt)->getName(); + + std::string val = (*propIt)->getValue(); + + if (name == "pass") + { + MaterialInstancePass* newPass = newInstance.createPass(); + std::vector<ScriptNode*> props2 = (*propIt)->getChildren(); + for (std::vector<ScriptNode*>::const_iterator propIt2 = props2.begin(); propIt2 != props2.end(); ++propIt2) + { + std::string name2 = (*propIt2)->getName(); + std::string val2 = (*propIt2)->getValue(); + + if (name2 == "shader_properties") + { + std::vector<ScriptNode*> shaderProps = (*propIt2)->getChildren(); + for (std::vector<ScriptNode*>::const_iterator shaderPropIt = shaderProps.begin(); shaderPropIt != shaderProps.end(); ++shaderPropIt) + { + std::string val = (*shaderPropIt)->getValue(); + newPass->mShaderProperties.setProperty((*shaderPropIt)->getName(), makeProperty(val)); + } + } + else if (name2 == "texture_unit") + { + MaterialInstanceTextureUnit* newTex = newPass->createTextureUnit(val2); + std::vector<ScriptNode*> texProps = (*propIt2)->getChildren(); + for (std::vector<ScriptNode*>::const_iterator texPropIt = texProps.begin(); texPropIt != texProps.end(); ++texPropIt) + { + std::string val = (*texPropIt)->getValue(); + newTex->setProperty((*texPropIt)->getName(), makeProperty(val)); + } + } + else + newPass->setProperty((*propIt2)->getName(), makeProperty(val2)); + } + } + else if (name == "parent") + newInstance.setParentInstance(val); + else + newInstance.setProperty((*propIt)->getName(), makeProperty(val)); + } + + if (newInstance.hasProperty("create_configuration")) + { + std::string config = retrieveValue<StringValue>(newInstance.getProperty("create_configuration"), NULL).get(); + newInstance.createForConfiguration (config, 0); + } + + mMaterials.insert (std::make_pair(it->first, newInstance)); + } + + // now that all materials are loaded, replace the parent names with the actual pointers to parent + for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it) + { + std::string parent = it->second.getParentInstance(); + if (parent != "") + { + if (mMaterials.find (it->second.getParentInstance()) == mMaterials.end()) + throw std::runtime_error ("Unable to find parent for material instance \"" + it->first + "\""); + it->second.setParent(&mMaterials.find(parent)->second); + } + } + } + + if (mPlatform->supportsShaderSerialization () && mReadMicrocodeCache && !anyShaderDirty) + { + std::string file = mPlatform->getCacheFolder () + "/shShaderCache.txt"; + if (boost::filesystem::exists(file)) + { + mPlatform->deserializeShaders (file); + } + } + } + + Factory::~Factory () + { + if (mPlatform->supportsShaderSerialization () && mWriteMicrocodeCache) + { + std::string file = mPlatform->getCacheFolder () + "/shShaderCache.txt"; + mPlatform->serializeShaders (file); + } + + if (mReadSourceCache) + { + // save the last modified time of shader sources + std::ofstream file; + file.open(std::string(mPlatform->getCacheFolder () + "/lastModified.txt").c_str()); + + for (LastModifiedMap::const_iterator it = mShadersLastModified.begin(); it != mShadersLastModified.end(); ++it) + { + file << it->first << "\n" << it->second << std::endl; + } + + file.close(); + } + + delete mPlatform; + sThis = 0; + } + + MaterialInstance* Factory::searchInstance (const std::string& name) + { + if (mMaterials.find(name) != mMaterials.end()) + return &mMaterials.find(name)->second; + + return NULL; + } + + MaterialInstance* Factory::findInstance (const std::string& name) + { + assert (mMaterials.find(name) != mMaterials.end()); + return &mMaterials.find(name)->second; + } + + MaterialInstance* Factory::requestMaterial (const std::string& name, const std::string& configuration, unsigned short lodIndex) + { + MaterialInstance* m = searchInstance (name); + + if (configuration != "Default" && mConfigurations.find(configuration) == mConfigurations.end()) + return NULL; + + if (m) + { + // make sure all lod techniques below (higher lod) exist + int i = lodIndex; + while (i>0) + { + --i; + m->createForConfiguration (configuration, i); + + if (mListener) + mListener->materialCreated (m, configuration, i); + } + + m->createForConfiguration (configuration, lodIndex); + if (mListener) + mListener->materialCreated (m, configuration, lodIndex); + } + return m; + } + + MaterialInstance* Factory::createMaterialInstance (const std::string& name, const std::string& parentInstance) + { + if (parentInstance != "" && mMaterials.find(parentInstance) == mMaterials.end()) + throw std::runtime_error ("trying to clone material that does not exist"); + + MaterialInstance newInstance(name, this); + + if (!mShadersEnabled) + newInstance.setShadersEnabled(false); + + if (parentInstance != "") + newInstance.setParent (&mMaterials.find(parentInstance)->second); + + newInstance.create(mPlatform); + + mMaterials.insert (std::make_pair(name, newInstance)); + + return &mMaterials.find(name)->second; + } + + void Factory::destroyMaterialInstance (const std::string& name) + { + if (mMaterials.find(name) != mMaterials.end()) + mMaterials.erase(name); + } + + void Factory::setShadersEnabled (bool enabled) + { + mShadersEnabled = enabled; + for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it) + { + it->second.setShadersEnabled(enabled); + } + } + + void Factory::setGlobalSetting (const std::string& name, const std::string& value) + { + bool changed = true; + if (mGlobalSettings.hasProperty(name)) + changed = (retrieveValue<StringValue>(mGlobalSettings.getProperty(name), NULL).get() != value); + + mGlobalSettings.setProperty (name, makeProperty<StringValue>(new StringValue(value))); + + if (changed) + { + for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it) + { + it->second.destroyAll(); + } + } + } + + void Factory::setSharedParameter (const std::string& name, PropertyValuePtr value) + { + mPlatform->setSharedParameter(name, value); + } + + ShaderSet* Factory::getShaderSet (const std::string& name) + { + return &mShaderSets.find(name)->second; + } + + Platform* Factory::getPlatform () + { + return mPlatform; + } + + Language Factory::getCurrentLanguage () + { + return mCurrentLanguage; + } + + void Factory::setCurrentLanguage (Language lang) + { + bool changed = (mCurrentLanguage != lang); + mCurrentLanguage = lang; + + if (changed) + { + for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it) + { + it->second.destroyAll(); + } + } + } + + MaterialInstance* Factory::getMaterialInstance (const std::string& name) + { + return findInstance(name); + } + + void Factory::setTextureAlias (const std::string& alias, const std::string& realName) + { + mTextureAliases[alias] = realName; + + // update the already existing texture units + for (std::map<TextureUnitState*, std::string>::iterator it = mTextureAliasInstances.begin(); it != mTextureAliasInstances.end(); ++it) + { + if (it->second == alias) + { + it->first->setTextureName(realName); + } + } + } + + std::string Factory::retrieveTextureAlias (const std::string& name) + { + if (mTextureAliases.find(name) != mTextureAliases.end()) + return mTextureAliases[name]; + else + return ""; + } + + PropertySetGet* Factory::getConfiguration (const std::string& name) + { + return &mConfigurations[name]; + } + + void Factory::registerConfiguration (const std::string& name, PropertySetGet configuration) + { + mConfigurations[name] = configuration; + mConfigurations[name].setParent (&mGlobalSettings); + } + + void Factory::registerLodConfiguration (int index, PropertySetGet configuration) + { + mLodConfigurations[index] = configuration; + } + + void Factory::setMaterialListener (MaterialListener* listener) + { + mListener = listener; + } + + void Factory::addTextureAliasInstance (const std::string& name, TextureUnitState* t) + { + mTextureAliasInstances[t] = name; + } + + void Factory::removeTextureAliasInstances (TextureUnitState* t) + { + mTextureAliasInstances.erase(t); + } + + void Factory::setActiveConfiguration (const std::string& configuration) + { + if (configuration == "Default") + mCurrentConfiguration = 0; + else + { + assert (mConfigurations.find(configuration) != mConfigurations.end()); + mCurrentConfiguration = &mConfigurations[configuration]; + } + } + + void Factory::setActiveLodLevel (int level) + { + if (level == 0) + mCurrentLodConfiguration = 0; + else + { + assert (mLodConfigurations.find(level) != mLodConfigurations.end()); + mCurrentLodConfiguration = &mLodConfigurations[level]; + } + } + + void Factory::setShaderDebugOutputEnabled (bool enabled) + { + mShaderDebugOutputEnabled = enabled; + } + + PropertySetGet* Factory::getCurrentGlobalSettings() + { + PropertySetGet* p = &mGlobalSettings; + + // current global settings are affected by active configuration & active lod configuration + + if (mCurrentConfiguration) + { + p = mCurrentConfiguration; + } + + if (mCurrentLodConfiguration) + { + mCurrentLodConfiguration->setParent(p); + p = mCurrentLodConfiguration; + } + + return p; + } + + void Factory::saveMaterials (const std::string& filename) + { + std::ofstream file; + file.open (filename.c_str ()); + + for (MaterialMap::iterator it = mMaterials.begin(); it != mMaterials.end(); ++it) + { + it->second.save(file); + } + + file.close(); + } + + void Factory::_ensureMaterial(const std::string& name, const std::string& configuration) + { + MaterialInstance* m = searchInstance (name); + assert(m); + m->createForConfiguration (configuration, 0); + } +} diff --git a/extern/shiny/Main/Factory.hpp b/extern/shiny/Main/Factory.hpp new file mode 100644 index 0000000000..799dd71eb0 --- /dev/null +++ b/extern/shiny/Main/Factory.hpp @@ -0,0 +1,207 @@ +#ifndef SH_FACTORY_H +#define SH_FACTORY_H + +#include <map> +#include <string> + +#include "MaterialInstance.hpp" +#include "ShaderSet.hpp" +#include "Language.hpp" + +namespace sh +{ + class Platform; + + typedef std::map<std::string, MaterialInstance> MaterialMap; + typedef std::map<std::string, ShaderSet> ShaderSetMap; + typedef std::map<std::string, PropertySetGet> ConfigurationMap; + typedef std::map<int, PropertySetGet> LodConfigurationMap; + typedef std::map<std::string, int> LastModifiedMap; + + typedef std::map<std::string, std::string> TextureAliasMap; + + /** + * @brief + * Allows you to be notified when a certain material was just created. Useful for changing material properties that you can't + * do in a .mat script (for example a series of animated textures) \n + * When receiving the event, you can get the platform material by calling m->getMaterial() + * and casting that to the platform specific material (e.g. for Ogre, sh::OgreMaterial) + */ + class MaterialListener + { + public: + virtual void materialCreated (MaterialInstance* m, const std::string& configuration, unsigned short lodIndex) = 0; + }; + + /** + * @brief + * The main interface class + */ + class Factory + { + public: + Factory(Platform* platform); + ///< @note Ownership of \a platform is transferred to this class, so you don't have to delete it. + + ~Factory(); + + /** + * Create a MaterialInstance, optionally copying all properties from \a parentInstance + * @param name name of the new instance + * @param name of the parent (optional) + * @return newly created instance + */ + MaterialInstance* createMaterialInstance (const std::string& name, const std::string& parentInstance = ""); + + /// @note It is safe to call this if the instance does not exist + void destroyMaterialInstance (const std::string& name); + + /// Use this to enable or disable shaders on-the-fly + void setShadersEnabled (bool enabled); + + /// write generated shaders to current directory, useful for debugging + void setShaderDebugOutputEnabled (bool enabled); + + /// Use this to manage user settings. \n + /// Global settings can be retrieved in shaders through a macro. \n + /// When a global setting is changed, the shaders that depend on them are recompiled automatically. + void setGlobalSetting (const std::string& name, const std::string& value); + + /// Adjusts the given shared parameter. \n + /// Internally, this will change all uniform parameters of this name marked with the macro \@shSharedParameter \n + /// @param name of the shared parameter + /// @param value of the parameter, use sh::makeProperty to construct this value + void setSharedParameter (const std::string& name, PropertyValuePtr value); + + Language getCurrentLanguage (); + + /// Switch between different shader languages (cg, glsl, hlsl) + void setCurrentLanguage (Language lang); + + /// Get a MaterialInstance by name + MaterialInstance* getMaterialInstance (const std::string& name); + + /// Register a configuration, which can then be used by switching the active material scheme + void registerConfiguration (const std::string& name, PropertySetGet configuration); + + /// Register a lod configuration, which can then be used by setting up lod distance values for the material \n + /// 0 refers to highest lod, so use 1 or higher as index parameter + void registerLodConfiguration (int index, PropertySetGet configuration); + + /// Set an alias name for a texture, the real name can then be retrieved with the "texture_alias" + /// property in a texture unit - this is useful if you don't know the name of your texture beforehand. \n + /// Example: \n + /// - In the material definition: texture_alias ReflectionMap \n + /// - At runtime: factory->setTextureAlias("ReflectionMap", "rtt_654654"); \n + /// You can call factory->setTextureAlias as many times as you want, and if the material was already created, its texture will be updated! + void setTextureAlias (const std::string& alias, const std::string& realName); + + /// Retrieve the real texture name for a texture alias (the real name is set by the user) + std::string retrieveTextureAlias (const std::string& name); + + /// Attach a listener for material created events + void setMaterialListener (MaterialListener* listener); + + /// Call this after you have set up basic stuff, like the shader language. + void loadAllFiles (); + + /// Controls writing of generated shader source code to the cache folder, so that the + /// (rather expensive) preprocessing step can be skipped on the next run. See Factory::setReadSourceCache \n + /// \note The default is off (no cache writing) + void setWriteSourceCache(bool write) { mWriteSourceCache = write; } + + /// Controls reading of generated shader sources from the cache folder + /// \note The default is off (no cache reading) + /// \note Even if microcode caching is enabled, generating (or caching) the source is still required due to the macros. + void setReadSourceCache(bool read) { mReadSourceCache = read; } + + /// Controls writing the microcode of the generated shaders to the cache folder. Microcode is machine independent + /// and loads very fast compared to regular compilation. Note that the availability of this feature depends on the \a Platform. + /// \note The default is off (no cache writing) + void setWriteMicrocodeCache(bool write) { mWriteMicrocodeCache = write; } + + /// Controls reading of shader microcode from the cache folder. Microcode is machine independent + /// and loads very fast compared to regular compilation. Note that the availability of this feature depends on the \a Platform. + /// \note The default is off (no cache reading) + void setReadMicrocodeCache(bool read) { mReadMicrocodeCache = read; } + + /// Saves all the materials that were initially loaded from the file with this name + void saveMaterials (const std::string& filename); + + static Factory& getInstance(); + ///< Return instance of this class. + + static Factory* getInstancePtr(); + + /// Make sure a material technique is loaded.\n + /// You will probably never have to use this. + void _ensureMaterial(const std::string& name, const std::string& configuration); + + private: + + MaterialInstance* requestMaterial (const std::string& name, const std::string& configuration, unsigned short lodIndex); + ShaderSet* getShaderSet (const std::string& name); + PropertySetGet* getConfiguration (const std::string& name); + Platform* getPlatform (); + + PropertySetGet* getCurrentGlobalSettings(); + + void addTextureAliasInstance (const std::string& name, TextureUnitState* t); + void removeTextureAliasInstances (TextureUnitState* t); + + std::string getCacheFolder () { return mPlatform->getCacheFolder (); } + bool getReadSourceCache() { return mReadSourceCache; } + bool getWriteSourceCache() { return mReadSourceCache; } + public: + bool getWriteMicrocodeCache() { return mWriteMicrocodeCache; } // Fixme + + private: + void setActiveConfiguration (const std::string& configuration); + void setActiveLodLevel (int level); + + bool getShaderDebugOutputEnabled() { return mShaderDebugOutputEnabled; } + + std::map<TextureUnitState*, std::string> mTextureAliasInstances; + + friend class Platform; + friend class MaterialInstance; + friend class ShaderInstance; + friend class ShaderSet; + friend class TextureUnitState; + + private: + static Factory* sThis; + + bool mShadersEnabled; + bool mShaderDebugOutputEnabled; + + bool mReadMicrocodeCache; + bool mWriteMicrocodeCache; + bool mReadSourceCache; + bool mWriteSourceCache; + + MaterialMap mMaterials; + ShaderSetMap mShaderSets; + ConfigurationMap mConfigurations; + LodConfigurationMap mLodConfigurations; + LastModifiedMap mShadersLastModified; + + PropertySetGet mGlobalSettings; + + PropertySetGet* mCurrentConfiguration; + PropertySetGet* mCurrentLodConfiguration; + + TextureAliasMap mTextureAliases; + + Language mCurrentLanguage; + + MaterialListener* mListener; + + Platform* mPlatform; + + MaterialInstance* findInstance (const std::string& name); + MaterialInstance* searchInstance (const std::string& name); + }; +} + +#endif diff --git a/extern/shiny/Main/Language.hpp b/extern/shiny/Main/Language.hpp new file mode 100644 index 0000000000..20bf8ed61c --- /dev/null +++ b/extern/shiny/Main/Language.hpp @@ -0,0 +1,16 @@ +#ifndef SH_LANGUAGE_H +#define SH_LANGUAGE_H + +namespace sh +{ + enum Language + { + Language_CG, + Language_HLSL, + Language_GLSL, + Language_Count, + Language_None + }; +} + +#endif diff --git a/extern/shiny/Main/MaterialInstance.cpp b/extern/shiny/Main/MaterialInstance.cpp new file mode 100644 index 0000000000..3abc781f61 --- /dev/null +++ b/extern/shiny/Main/MaterialInstance.cpp @@ -0,0 +1,218 @@ +#include "MaterialInstance.hpp" + +#include <stdexcept> + +#include "Factory.hpp" +#include "ShaderSet.hpp" + +namespace sh +{ + MaterialInstance::MaterialInstance (const std::string& name, Factory* f) + : mName(name) + , mShadersEnabled(true) + , mFactory(f) + , mListener(NULL) + { + } + + MaterialInstance::~MaterialInstance () + { + } + + void MaterialInstance::setParentInstance (const std::string& name) + { + mParentInstance = name; + } + + std::string MaterialInstance::getParentInstance () + { + return mParentInstance; + } + + void MaterialInstance::create (Platform* platform) + { + mMaterial = platform->createMaterial(mName); + + if (hasProperty ("shadow_caster_material")) + mMaterial->setShadowCasterMaterial (retrieveValue<StringValue>(getProperty("shadow_caster_material"), NULL).get()); + + if (hasProperty ("lod_values")) + mMaterial->setLodLevels (retrieveValue<StringValue>(getProperty("lod_values"), NULL).get()); + } + + void MaterialInstance::destroyAll () + { + if (hasProperty("create_configuration")) + return; + mMaterial->removeAll(); + mTexUnits.clear(); + } + + void MaterialInstance::setProperty (const std::string& name, PropertyValuePtr value) + { + PropertySetGet::setProperty (name, value); + destroyAll(); // trigger updates + } + + void MaterialInstance::createForConfiguration (const std::string& configuration, unsigned short lodIndex) + { + bool res = mMaterial->createConfiguration(configuration, lodIndex); + if (!res) + return; // listener was false positive + + if (mListener) + mListener->requestedConfiguration (this, configuration); + + mFactory->setActiveConfiguration (configuration); + mFactory->setActiveLodLevel (lodIndex); + + bool allowFixedFunction = true; + if (!mShadersEnabled && hasProperty("allow_fixed_function")) + { + allowFixedFunction = retrieveValue<BooleanValue>(getProperty("allow_fixed_function"), NULL).get(); + } + + // get passes of the top-most parent + PassVector passes = getPasses(); + if (passes.size() == 0) + throw std::runtime_error ("material \"" + mName + "\" does not have any passes"); + + for (PassVector::iterator it = passes.begin(); it != passes.end(); ++it) + { + boost::shared_ptr<Pass> pass = mMaterial->createPass (configuration, lodIndex); + it->copyAll (pass.get(), this); + + // texture samplers used in the shaders + std::vector<std::string> usedTextureSamplersVertex; + std::vector<std::string> usedTextureSamplersFragment; + + PropertySetGet* context = this; + + // create or retrieve shaders + bool hasVertex = it->hasProperty("vertex_program"); + bool hasFragment = it->hasProperty("fragment_program"); + if (mShadersEnabled || !allowFixedFunction) + { + it->setContext(context); + it->mShaderProperties.setContext(context); + if (hasVertex) + { + ShaderSet* vertex = mFactory->getShaderSet(retrieveValue<StringValue>(it->getProperty("vertex_program"), context).get()); + ShaderInstance* v = vertex->getInstance(&it->mShaderProperties); + if (v) + { + pass->assignProgram (GPT_Vertex, v->getName()); + v->setUniformParameters (pass, &it->mShaderProperties); + + std::vector<std::string> sharedParams = v->getSharedParameters (); + for (std::vector<std::string>::iterator it = sharedParams.begin(); it != sharedParams.end(); ++it) + { + pass->addSharedParameter (GPT_Vertex, *it); + } + + std::vector<std::string> vector = v->getUsedSamplers (); + usedTextureSamplersVertex.insert(usedTextureSamplersVertex.end(), vector.begin(), vector.end()); + } + } + if (hasFragment) + { + ShaderSet* fragment = mFactory->getShaderSet(retrieveValue<StringValue>(it->getProperty("fragment_program"), context).get()); + ShaderInstance* f = fragment->getInstance(&it->mShaderProperties); + if (f) + { + pass->assignProgram (GPT_Fragment, f->getName()); + f->setUniformParameters (pass, &it->mShaderProperties); + + std::vector<std::string> sharedParams = f->getSharedParameters (); + for (std::vector<std::string>::iterator it = sharedParams.begin(); it != sharedParams.end(); ++it) + { + pass->addSharedParameter (GPT_Fragment, *it); + } + + std::vector<std::string> vector = f->getUsedSamplers (); + usedTextureSamplersFragment.insert(usedTextureSamplersFragment.end(), vector.begin(), vector.end()); + } + } + } + + // create texture units + std::vector<MaterialInstanceTextureUnit> texUnits = it->getTexUnits(); + int i=0; + for (std::vector<MaterialInstanceTextureUnit>::iterator texIt = texUnits.begin(); texIt != texUnits.end(); ++texIt ) + { + // only create those that are needed by the shader, OR those marked to be created in fixed function pipeline if shaders are disabled + bool foundVertex = std::find(usedTextureSamplersVertex.begin(), usedTextureSamplersVertex.end(), texIt->getName()) != usedTextureSamplersVertex.end(); + bool foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end(); + if ( (foundVertex || foundFragment) + || (((!mShadersEnabled || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get())) + { + boost::shared_ptr<TextureUnitState> texUnit = pass->createTextureUnitState (); + texIt->copyAll (texUnit.get(), context); + + mTexUnits.push_back(texUnit); + + // set texture unit indices (required by GLSL) + if (mShadersEnabled && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL) + { + pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i); + + ++i; + } + } + } + } + + if (mListener) + mListener->createdConfiguration (this, configuration); + } + + Material* MaterialInstance::getMaterial () + { + return mMaterial.get(); + } + + MaterialInstancePass* MaterialInstance::createPass () + { + mPasses.push_back (MaterialInstancePass()); + mPasses.back().setContext(this); + return &mPasses.back(); + } + + PassVector MaterialInstance::getPasses() + { + if (mParent) + return static_cast<MaterialInstance*>(mParent)->getPasses(); + else + return mPasses; + } + + void MaterialInstance::setShadersEnabled (bool enabled) + { + if (enabled == mShadersEnabled) + return; + mShadersEnabled = enabled; + + // trigger updates + if (mMaterial.get()) + destroyAll(); + } + + void MaterialInstance::save (std::ofstream& stream) + { + stream << "material " << mName << "\n" + << "{\n"; + + if (mParent) + { + stream << "\t" << static_cast<MaterialInstance*>(mParent)->getName() << "\n"; + } + + const PropertyMap& properties = listProperties (); + for (PropertyMap::const_iterator it = properties.begin(); it != properties.end(); ++it) + { + stream << "\t" << it->first << " " << retrieveValue<StringValue>(getProperty(it->first), NULL).get() << "\n"; + } + + stream << "}\n"; + } +} diff --git a/extern/shiny/Main/MaterialInstance.hpp b/extern/shiny/Main/MaterialInstance.hpp new file mode 100644 index 0000000000..000f9d60c9 --- /dev/null +++ b/extern/shiny/Main/MaterialInstance.hpp @@ -0,0 +1,104 @@ +#ifndef SH_MATERIALINSTANCE_H +#define SH_MATERIALINSTANCE_H + +#include <vector> +#include <fstream> + +#include "PropertyBase.hpp" +#include "Platform.hpp" +#include "MaterialInstancePass.hpp" + +namespace sh +{ + class Factory; + + typedef std::vector<MaterialInstancePass> PassVector; + + /** + * @brief + * Allows you to be notified when a certain configuration for a material was just about to be created. \n + * Useful for adjusting some properties prior to the material being created (Or you could also re-create + * the whole material from scratch, i.e. use this as a method to create this material entirely in code) + */ + class MaterialInstanceListener + { + public: + virtual void requestedConfiguration (MaterialInstance* m, const std::string& configuration) = 0; ///< called before creating + virtual void createdConfiguration (MaterialInstance* m, const std::string& configuration) = 0; ///< called after creating + }; + + /** + * @brief + * A specific material instance, which has all required properties set + * (for example the diffuse & normal map, ambient/diffuse/specular values). \n + * Depending on these properties, the system will automatically select a shader permutation + * that suits these and create the backend materials / passes (provided by the \a Platform class). + */ + class MaterialInstance : public PropertySetGet + { + public: + MaterialInstance (const std::string& name, Factory* f); + virtual ~MaterialInstance (); + + MaterialInstancePass* createPass (); + PassVector getPasses(); ///< gets the passes of the top-most parent + + /// @attention Because the backend material passes are created on demand, the returned material here might not contain anything yet! + /// The only place where you should use this method, is for the MaterialInstance given by the MaterialListener::materialCreated event! + Material* getMaterial(); + + /// attach a \a MaterialInstanceListener to this specific material (as opposed to \a MaterialListener, which listens to all materials) + void setListener (MaterialInstanceListener* l) { mListener = l; } + + std::string getName() { return mName; } + + virtual void setProperty (const std::string& name, PropertyValuePtr value); + + private: + void setParentInstance (const std::string& name); + std::string getParentInstance (); + + void create (Platform* platform); + void createForConfiguration (const std::string& configuration, unsigned short lodIndex); + + void destroyAll (); + + void setShadersEnabled (bool enabled); + + void setSourceFile(const std::string& sourceFile) { mSourceFile = sourceFile; } + + std::string getSourceFile() { return mSourceFile; } + ///< get the name of the file this material was read from, or empty if it was created dynamically by code + + void save (std::ofstream& stream); + ///< this will only save the properties, not the passes and texture units, and as such + /// is only intended to be used for derived materials + + friend class Factory; + + + private: + std::string mParentInstance; + ///< this is only used during the file-loading phase. an instance could be loaded before its parent is loaded, + /// so initially only the parent's name is written to this member. + /// once all instances are loaded, the actual mParent pointer (from PropertySetGet class) can be set + + std::vector< boost::shared_ptr<TextureUnitState> > mTexUnits; + + MaterialInstanceListener* mListener; + + PassVector mPasses; + + std::string mName; + + std::string mSourceFile; + + boost::shared_ptr<Material> mMaterial; + + bool mShadersEnabled; + + Factory* mFactory; + }; +} + +#endif diff --git a/extern/shiny/Main/MaterialInstancePass.cpp b/extern/shiny/Main/MaterialInstancePass.cpp new file mode 100644 index 0000000000..b14476f4e7 --- /dev/null +++ b/extern/shiny/Main/MaterialInstancePass.cpp @@ -0,0 +1,16 @@ +#include "MaterialInstancePass.hpp" + +namespace sh +{ + + MaterialInstanceTextureUnit* MaterialInstancePass::createTextureUnit (const std::string& name) + { + mTexUnits.push_back(MaterialInstanceTextureUnit(name)); + return &mTexUnits.back(); + } + + std::vector <MaterialInstanceTextureUnit> MaterialInstancePass::getTexUnits () + { + return mTexUnits; + } +} diff --git a/extern/shiny/Main/MaterialInstancePass.hpp b/extern/shiny/Main/MaterialInstancePass.hpp new file mode 100644 index 0000000000..7d7330f705 --- /dev/null +++ b/extern/shiny/Main/MaterialInstancePass.hpp @@ -0,0 +1,29 @@ +#ifndef SH_MATERIALINSTANCEPASS_H +#define SH_MATERIALINSTANCEPASS_H + +#include <vector> + +#include "PropertyBase.hpp" +#include "MaterialInstanceTextureUnit.hpp" + +namespace sh +{ + /** + * @brief + * Holds properties of a single texture unit in a \a MaterialInstancePass. \n + * No inheritance here for now. + */ + class MaterialInstancePass : public PropertySetGet + { + public: + MaterialInstanceTextureUnit* createTextureUnit (const std::string& name); + + PropertySetGet mShaderProperties; + + std::vector <MaterialInstanceTextureUnit> getTexUnits (); + private: + std::vector <MaterialInstanceTextureUnit> mTexUnits; + }; +} + +#endif diff --git a/extern/shiny/Main/MaterialInstanceTextureUnit.cpp b/extern/shiny/Main/MaterialInstanceTextureUnit.cpp new file mode 100644 index 0000000000..0e3078af34 --- /dev/null +++ b/extern/shiny/Main/MaterialInstanceTextureUnit.cpp @@ -0,0 +1,14 @@ +#include "MaterialInstanceTextureUnit.hpp" + +namespace sh +{ + MaterialInstanceTextureUnit::MaterialInstanceTextureUnit (const std::string& name) + : mName(name) + { + } + + std::string MaterialInstanceTextureUnit::getName() const + { + return mName; + } +} diff --git a/extern/shiny/Main/MaterialInstanceTextureUnit.hpp b/extern/shiny/Main/MaterialInstanceTextureUnit.hpp new file mode 100644 index 0000000000..ae9f54fd2d --- /dev/null +++ b/extern/shiny/Main/MaterialInstanceTextureUnit.hpp @@ -0,0 +1,26 @@ +#ifndef SH_MATERIALINSTANCETEXTUREUNIT_H +#define SH_MATERIALINSTANCETEXTUREUNIT_H + +#include "PropertyBase.hpp" + +namespace sh +{ + /** + * @brief + * A single texture unit state that belongs to a \a MaterialInstancePass \n + * this is not the real "backend" \a TextureUnitState (provided by \a Platform), + * it is merely a placeholder for properties. \n + * @note The backend \a TextureUnitState will only be created if this texture unit is + * actually used (i.e. referenced in the shader, or marked with property create_in_ffp = true). + */ + class MaterialInstanceTextureUnit : public PropertySetGet + { + public: + MaterialInstanceTextureUnit (const std::string& name); + std::string getName() const; + private: + std::string mName; + }; +} + +#endif diff --git a/extern/shiny/Main/Platform.cpp b/extern/shiny/Main/Platform.cpp new file mode 100644 index 0000000000..94b4f872ae --- /dev/null +++ b/extern/shiny/Main/Platform.cpp @@ -0,0 +1,94 @@ +#include "Platform.hpp" + +#include <stdexcept> + +#include "Factory.hpp" + +namespace sh +{ + Platform::Platform (const std::string& basePath) + : mBasePath(basePath) + , mCacheFolder("./") + , mShaderCachingEnabled(false) + { + } + + Platform::~Platform () + { + } + + void Platform::setFactory (Factory* factory) + { + mFactory = factory; + } + + std::string Platform::getBasePath () + { + return mBasePath; + } + + bool Platform::supportsMaterialQueuedListener () + { + return false; + } + + bool Platform::supportsShaderSerialization () + { + return false; + } + + MaterialInstance* Platform::fireMaterialRequested (const std::string& name, const std::string& configuration, unsigned short lodIndex) + { + return mFactory->requestMaterial (name, configuration, lodIndex); + } + + void Platform::serializeShaders (const std::string& file) + { + throw std::runtime_error ("Shader serialization not supported by this platform"); + } + + void Platform::deserializeShaders (const std::string& file) + { + throw std::runtime_error ("Shader serialization not supported by this platform"); + } + + void Platform::setCacheFolder (const std::string& folder) + { + mCacheFolder = folder; + } + + void Platform::setShaderCachingEnabled (bool enabled) + { + mShaderCachingEnabled = enabled; + } + + std::string Platform::getCacheFolder() const + { + return mCacheFolder; + } + + // ------------------------------------------------------------------------------ + + bool TextureUnitState::setPropertyOverride (const std::string& name, PropertyValuePtr& value, PropertySetGet *context) + { + if (name == "texture_alias") + { + std::string aliasName = retrieveValue<StringValue>(value, context).get(); + + Factory::getInstance().addTextureAliasInstance (aliasName, this); + + setTextureName (Factory::getInstance().retrieveTextureAlias (aliasName)); + + return true; + } + else + return false; + } + + TextureUnitState::~TextureUnitState() + { + Factory* f = Factory::getInstancePtr (); + if (f) + f->removeTextureAliasInstances (this); + } +} diff --git a/extern/shiny/Main/Platform.hpp b/extern/shiny/Main/Platform.hpp new file mode 100644 index 0000000000..1b095e9576 --- /dev/null +++ b/extern/shiny/Main/Platform.hpp @@ -0,0 +1,145 @@ +#ifndef SH_PLATFORM_H +#define SH_PLATFORM_H + +#include <string> + +#include <boost/shared_ptr.hpp> + +#include "Language.hpp" +#include "PropertyBase.hpp" + +namespace sh +{ + class Factory; + class MaterialInstance; + + enum GpuProgramType + { + GPT_Vertex, + GPT_Fragment + // GPT_Geometry + }; + + // These classes are supposed to be filled by the platform implementation + class GpuProgram + { + public: + virtual bool getSupported () = 0; ///< @return true if the compilation was successful + + /// @param name name of the uniform in the shader + /// @param autoConstantName name of the auto constant (for example world_viewproj_matrix) + /// @param extraInfo if any extra info is needed (e.g. light index), put it here + virtual void setAutoConstant (const std::string& name, const std::string& autoConstantName, const std::string& extraInfo = "") = 0; + }; + + class TextureUnitState : public PropertySet + { + public: + virtual ~TextureUnitState(); + + virtual void setTextureName (const std::string& textureName) = 0; + + protected: + virtual bool setPropertyOverride (const std::string& name, PropertyValuePtr& value, PropertySetGet *context); + }; + + class Pass : public PropertySet + { + public: + virtual boost::shared_ptr<TextureUnitState> createTextureUnitState () = 0; + virtual void assignProgram (GpuProgramType type, const std::string& name) = 0; + + /// @param type gpu program type + /// @param name name of the uniform in the shader + /// @param vt type of value, e.g. vector4 + /// @param value value to set + /// @param context used for retrieving linked values + virtual void setGpuConstant (int type, const std::string& name, ValueType vt, PropertyValuePtr value, PropertySetGet* context) = 0; + + virtual void setTextureUnitIndex (int programType, const std::string& name, int index) = 0; + + virtual void addSharedParameter (int type, const std::string& name) = 0; + }; + + class Material : public PropertySet + { + public: + virtual boost::shared_ptr<Pass> createPass (const std::string& configuration, unsigned short lodIndex) = 0; + virtual bool createConfiguration (const std::string& name, unsigned short lodIndex) = 0; ///< @return false if already exists + virtual void removeAll () = 0; ///< remove all configurations + + virtual void setLodLevels (const std::string& lodLevels) = 0; + + virtual void setShadowCasterMaterial (const std::string& name) = 0; + }; + + class Platform + { + public: + Platform (const std::string& basePath); + virtual ~Platform (); + + void setShaderCachingEnabled (bool enabled); + + /// set the folder to use for shader caching + void setCacheFolder (const std::string& folder); + + private: + virtual boost::shared_ptr<Material> createMaterial (const std::string& name) = 0; + + virtual boost::shared_ptr<GpuProgram> createGpuProgram ( + GpuProgramType type, + const std::string& compileArguments, + const std::string& name, const std::string& profile, + const std::string& source, Language lang) = 0; + + virtual void setSharedParameter (const std::string& name, PropertyValuePtr value) = 0; + + virtual bool isProfileSupported (const std::string& profile) = 0; + + virtual void serializeShaders (const std::string& file); + virtual void deserializeShaders (const std::string& file); + + std::string getCacheFolder () const; + + friend class Factory; + friend class MaterialInstance; + friend class ShaderInstance; + + protected: + /** + * this will be \a true if the platform supports serialization (writing shader microcode + * to disk) and deserialization (create gpu program from saved microcode) + */ + virtual bool supportsShaderSerialization (); + + /** + * this will be \a true if the platform supports a listener that notifies the system + * whenever a material is requested for rendering. if this is supported, shaders can be + * compiled on-demand when needed (and not earlier) + * @todo the Factory is not designed yet to handle the case where this method returns false + */ + virtual bool supportsMaterialQueuedListener (); + + /** + * fire event: material requested for rendering + * @param name material name + * @param configuration requested configuration + */ + MaterialInstance* fireMaterialRequested (const std::string& name, const std::string& configuration, unsigned short lodIndex); + + std::string mCacheFolder; + Factory* mFactory; + + protected: + bool mShaderCachingEnabled; + + private: + void setFactory (Factory* factory); + + std::string mBasePath; + std::string getBasePath(); + }; +} + +#endif diff --git a/extern/shiny/Main/Preprocessor.cpp b/extern/shiny/Main/Preprocessor.cpp new file mode 100644 index 0000000000..1a97668bcc --- /dev/null +++ b/extern/shiny/Main/Preprocessor.cpp @@ -0,0 +1,99 @@ +#include "Preprocessor.hpp" + +#include <boost/wave.hpp> +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +namespace sh +{ + std::string Preprocessor::preprocess (std::string source, const std::string& includePath, std::vector<std::string> definitions, const std::string& name) + { + std::stringstream returnString; + + // current file position is saved for exception handling + boost::wave::util::file_position_type current_position; + + try + { + // This token type is one of the central types used throughout the library. + // It is a template parameter to some of the public classes and instances + // of this type are returned from the iterators. + typedef boost::wave::cpplexer::lex_token<> token_type; + + // The template boost::wave::cpplexer::lex_iterator<> is the lexer type to + // to use as the token source for the preprocessing engine. It is + // parametrized with the token type. + typedef boost::wave::cpplexer::lex_iterator<token_type> lex_iterator_type; + + // This is the resulting context type. The first template parameter should + // match the iterator type used during construction of the context + // instance (see below). It is the type of the underlying input stream. + typedef boost::wave::context<std::string::iterator, lex_iterator_type + , boost::wave::iteration_context_policies::load_file_to_string, + emit_custom_line_directives_hooks> + context_type; + + // The preprocessor iterator shouldn't be constructed directly. It is + // generated through a wave::context<> object. This wave:context<> object + // is additionally used to initialize and define different parameters of + // the actual preprocessing. + // + // The preprocessing of the input stream is done on the fly behind the + // scenes during iteration over the range of context_type::iterator_type + // instances. + context_type ctx (source.begin(), source.end(), name.c_str()); + ctx.add_include_path(includePath.c_str()); + for (std::vector<std::string>::iterator it = definitions.begin(); it != definitions.end(); ++it) + { + ctx.add_macro_definition(*it); + } + + // Get the preprocessor iterators and use them to generate the token + // sequence. + context_type::iterator_type first = ctx.begin(); + context_type::iterator_type last = ctx.end(); + + // The input stream is preprocessed for you while iterating over the range + // [first, last). The dereferenced iterator returns tokens holding + // information about the preprocessed input stream, such as token type, + // token value, and position. + while (first != last) + { + current_position = (*first).get_position(); + returnString << (*first).get_value(); + ++first; + } + } + catch (boost::wave::cpp_exception const& e) + { + // some preprocessing error + std::stringstream error; + error + << e.file_name() << "(" << e.line_no() << "): " + << e.description(); + throw std::runtime_error(error.str()); + } + catch (std::exception const& e) + { + // use last recognized token to retrieve the error position + std::stringstream error; + error + << current_position.get_file() + << "(" << current_position.get_line() << "): " + << "exception caught: " << e.what(); + throw std::runtime_error(error.str()); + } + catch (...) + { + // use last recognized token to retrieve the error position + std::stringstream error; + error + << current_position.get_file() + << "(" << current_position.get_line() << "): " + << "unexpected exception caught."; + throw std::runtime_error(error.str()); + } + + return returnString.str(); + } +} diff --git a/extern/shiny/Main/Preprocessor.hpp b/extern/shiny/Main/Preprocessor.hpp new file mode 100644 index 0000000000..7ee30ae7fc --- /dev/null +++ b/extern/shiny/Main/Preprocessor.hpp @@ -0,0 +1,69 @@ +#ifndef SH_PREPROCESSOR_H +#define SH_PREPROCESSOR_H + +#include <string> +#include <vector> + +#include <cstdio> +#include <ostream> +#include <string> +#include <algorithm> + +#include <boost/assert.hpp> +#include <boost/config.hpp> + +#include <boost/wave/cpp_throw.hpp> +#include <boost/wave/cpp_exceptions.hpp> +#include <boost/wave/token_ids.hpp> +#include <boost/wave/util/macro_helpers.hpp> +#include <boost/wave/preprocessing_hooks.hpp> + +namespace sh +{ + /** + * @brief A simple interface for the boost::wave preprocessor + */ + class Preprocessor + { + public: + /** + * @brief Run a shader source string through the preprocessor + * @param source source string + * @param includePath path to search for includes (that are included with #include) + * @param definitions macros to predefine (vector of strings of the format MACRO=value, or just MACRO to define it as 1) + * @param name name to use for error messages + * @return processed string + */ + static std::string preprocess (std::string source, const std::string& includePath, std::vector<std::string> definitions, const std::string& name); + }; + + + + class emit_custom_line_directives_hooks + : public boost::wave::context_policies::default_preprocessing_hooks + { + public: + + template <typename ContextT, typename ContainerT> + bool + emit_line_directive(ContextT const& ctx, ContainerT &pending, + typename ContextT::token_type const& act_token) + { + // emit a #line directive showing the relative filename instead + typename ContextT::position_type pos = act_token.get_position(); + unsigned int column = 1; + + typedef typename ContextT::token_type result_type; + + // no line directives for now + pos.set_column(column); + pending.push_back(result_type(boost::wave::T_GENERATEDNEWLINE, "\n", pos)); + + return true; + } + }; + + +} + +#endif diff --git a/extern/shiny/Main/PropertyBase.cpp b/extern/shiny/Main/PropertyBase.cpp new file mode 100644 index 0000000000..0c39e5c1e7 --- /dev/null +++ b/extern/shiny/Main/PropertyBase.cpp @@ -0,0 +1,268 @@ +#include "PropertyBase.hpp" + +#include <vector> +#include <iostream> + +#include <boost/lexical_cast.hpp> +#include <boost/algorithm/string.hpp> + +namespace sh +{ + + IntValue::IntValue(int in) + : mValue(in) + { + } + + IntValue::IntValue(const std::string& in) + { + mValue = boost::lexical_cast<int>(in); + } + + std::string IntValue::serialize() + { + return boost::lexical_cast<std::string>(mValue); + } + + // ------------------------------------------------------------------------------ + + BooleanValue::BooleanValue (bool in) + : mValue(in) + { + } + + BooleanValue::BooleanValue (const std::string& in) + { + if (in == "true") + mValue = true; + else if (in == "false") + mValue = false; + else + { + std::cerr << "sh::BooleanValue: Warning: Unrecognized value \"" << in << "\" for property value of type BooleanValue" << std::endl; + mValue = false; + } + } + + std::string BooleanValue::serialize () + { + if (mValue) + return "true"; + else + return "false"; + } + + // ------------------------------------------------------------------------------ + + StringValue::StringValue (const std::string& in) + { + mStringValue = in; + } + + std::string StringValue::serialize() + { + return mStringValue; + } + + // ------------------------------------------------------------------------------ + + LinkedValue::LinkedValue (const std::string& in) + { + mStringValue = in; + mStringValue.erase(0, 1); + } + + std::string LinkedValue::serialize() + { + throw std::runtime_error ("can't directly get a linked value"); + } + + std::string LinkedValue::get(PropertySetGet* context) const + { + PropertyValuePtr p = context->getProperty(mStringValue); + return retrieveValue<StringValue>(p, NULL).get(); + } + + // ------------------------------------------------------------------------------ + + FloatValue::FloatValue (float in) + { + mValue = in; + } + + FloatValue::FloatValue (const std::string& in) + { + mValue = boost::lexical_cast<float>(in); + } + + std::string FloatValue::serialize () + { + return boost::lexical_cast<std::string>(mValue); + } + + // ------------------------------------------------------------------------------ + + Vector2::Vector2 (float x, float y) + : mX(x) + , mY(y) + { + } + + Vector2::Vector2 (const std::string& in) + { + std::vector<std::string> tokens; + boost::split(tokens, in, boost::is_any_of(" ")); + assert ((tokens.size() == 2) && "Invalid Vector2 conversion"); + mX = boost::lexical_cast<float> (tokens[0]); + mY = boost::lexical_cast<float> (tokens[1]); + } + + std::string Vector2::serialize () + { + return boost::lexical_cast<std::string>(mX) + " " + + boost::lexical_cast<std::string>(mY); + } + + // ------------------------------------------------------------------------------ + + Vector3::Vector3 (float x, float y, float z) + : mX(x) + , mY(y) + , mZ(z) + { + } + + Vector3::Vector3 (const std::string& in) + { + std::vector<std::string> tokens; + boost::split(tokens, in, boost::is_any_of(" ")); + assert ((tokens.size() == 3) && "Invalid Vector3 conversion"); + mX = boost::lexical_cast<float> (tokens[0]); + mY = boost::lexical_cast<float> (tokens[1]); + mZ = boost::lexical_cast<float> (tokens[2]); + } + + std::string Vector3::serialize () + { + return boost::lexical_cast<std::string>(mX) + " " + + boost::lexical_cast<std::string>(mY) + " " + + boost::lexical_cast<std::string>(mZ); + } + + // ------------------------------------------------------------------------------ + + Vector4::Vector4 (float x, float y, float z, float w) + : mX(x) + , mY(y) + , mZ(z) + , mW(w) + { + } + + Vector4::Vector4 (const std::string& in) + { + std::vector<std::string> tokens; + boost::split(tokens, in, boost::is_any_of(" ")); + assert ((tokens.size() == 4) && "Invalid Vector4 conversion"); + mX = boost::lexical_cast<float> (tokens[0]); + mY = boost::lexical_cast<float> (tokens[1]); + mZ = boost::lexical_cast<float> (tokens[2]); + mW = boost::lexical_cast<float> (tokens[3]); + } + + std::string Vector4::serialize () + { + return boost::lexical_cast<std::string>(mX) + " " + + boost::lexical_cast<std::string>(mY) + " " + + boost::lexical_cast<std::string>(mZ) + " " + + boost::lexical_cast<std::string>(mW); + } + + // ------------------------------------------------------------------------------ + + void PropertySet::setProperty (const std::string& name, PropertyValuePtr &value, PropertySetGet* context) + { + if (!setPropertyOverride (name, value, context)) + std::cerr << "sh::PropertySet: Warning: No match for property with name '" << name << "'" << std::endl; + } + + bool PropertySet::setPropertyOverride (const std::string& name, PropertyValuePtr &value, PropertySetGet* context) + { + // if we got here, none of the sub-classes was able to make use of the property + return false; + } + + // ------------------------------------------------------------------------------ + + PropertySetGet::PropertySetGet (PropertySetGet* parent) + : mParent(parent) + , mContext(NULL) + { + } + + PropertySetGet::PropertySetGet () + : mParent(NULL) + , mContext(NULL) + { + } + + void PropertySetGet::setParent (PropertySetGet* parent) + { + mParent = parent; + } + + void PropertySetGet::setContext (PropertySetGet* context) + { + mContext = context; + } + + PropertySetGet* PropertySetGet::getContext() + { + return mContext; + } + + void PropertySetGet::setProperty (const std::string& name, PropertyValuePtr value) + { + mProperties [name] = value; + } + + PropertyValuePtr& PropertySetGet::getProperty (const std::string& name) + { + bool found = (mProperties.find(name) != mProperties.end()); + + if (!found) + { + if (!mParent) + throw std::runtime_error ("Trying to retrieve property \"" + name + "\" that does not exist"); + else + return mParent->getProperty (name); + } + else + return mProperties[name]; + } + + bool PropertySetGet::hasProperty (const std::string& name) + { + bool found = (mProperties.find(name) != mProperties.end()); + + if (!found) + { + if (!mParent) + return false; + else + return mParent->hasProperty (name); + } + else + return true; + } + + void PropertySetGet::copyAll (PropertySet* target, PropertySetGet* context) + { + if (mParent) + mParent->copyAll (target, context); + for (PropertyMap::iterator it = mProperties.begin(); it != mProperties.end(); ++it) + { + target->setProperty(it->first, it->second, context); + } + } +} diff --git a/extern/shiny/Main/PropertyBase.hpp b/extern/shiny/Main/PropertyBase.hpp new file mode 100644 index 0000000000..240acce81b --- /dev/null +++ b/extern/shiny/Main/PropertyBase.hpp @@ -0,0 +1,235 @@ +#ifndef SH_PROPERTYBASE_H +#define SH_PROPERTYBASE_H + +#include <string> +#include <map> + +#include <boost/shared_ptr.hpp> + +namespace sh +{ + class StringValue; + class PropertySetGet; + class LinkedValue; + + enum ValueType + { + VT_String, + VT_Int, + VT_Float, + VT_Vector2, + VT_Vector3, + VT_Vector4 + }; + + class PropertyValue + { + public: + PropertyValue() {} + + virtual ~PropertyValue() {} + + std::string _getStringValue() { return mStringValue; } + + virtual std::string serialize() = 0; + + protected: + std::string mStringValue; ///< this will possibly not contain anything in the specialised classes + }; + typedef boost::shared_ptr<PropertyValue> PropertyValuePtr; + + class StringValue : public PropertyValue + { + public: + StringValue (const std::string& in); + std::string get() const { return mStringValue; } + + virtual std::string serialize(); + }; + + /** + * @brief Used for retrieving a named property from a context + */ + class LinkedValue : public PropertyValue + { + public: + LinkedValue (const std::string& in); + + std::string get(PropertySetGet* context) const; + + virtual std::string serialize(); + }; + + class FloatValue : public PropertyValue + { + public: + FloatValue (float in); + FloatValue (const std::string& in); + float get() const { return mValue; } + + virtual std::string serialize(); + private: + float mValue; + }; + + class IntValue : public PropertyValue + { + public: + IntValue (int in); + IntValue (const std::string& in); + int get() const { return mValue; } + + virtual std::string serialize(); + private: + int mValue; + }; + + class BooleanValue : public PropertyValue + { + public: + BooleanValue (bool in); + BooleanValue (const std::string& in); + bool get() const { return mValue; } + + virtual std::string serialize(); + private: + bool mValue; + }; + + class Vector2 : public PropertyValue + { + public: + Vector2 (float x, float y); + Vector2 (const std::string& in); + + float mX, mY; + + virtual std::string serialize(); + }; + + class Vector3 : public PropertyValue + { + public: + Vector3 (float x, float y, float z); + Vector3 (const std::string& in); + + float mX, mY, mZ; + + virtual std::string serialize(); + }; + + class Vector4 : public PropertyValue + { + public: + Vector4 (float x, float y, float z, float w); + Vector4 (const std::string& in); + + float mX, mY, mZ, mW; + + virtual std::string serialize(); + }; + + /// \brief base class that allows setting properties with any kind of value-type + class PropertySet + { + public: + void setProperty (const std::string& name, PropertyValuePtr& value, PropertySetGet* context); + + protected: + virtual bool setPropertyOverride (const std::string& name, PropertyValuePtr& value, PropertySetGet* context); + ///< @return \a true if the specified property was found, or false otherwise + }; + + typedef std::map<std::string, PropertyValuePtr> PropertyMap; + + /// \brief base class that allows setting properties with any kind of value-type and retrieving them + class PropertySetGet + { + public: + PropertySetGet (PropertySetGet* parent); + PropertySetGet (); + + virtual ~PropertySetGet() {} + + void copyAll (PropertySet* target, PropertySetGet* context); ///< call setProperty for each property/value pair stored in \a this + + void setParent (PropertySetGet* parent); + void setContext (PropertySetGet* context); + PropertySetGet* getContext(); + + virtual void setProperty (const std::string& name, PropertyValuePtr value); + PropertyValuePtr& getProperty (const std::string& name); + + const PropertyMap& listProperties() { return mProperties; } + + bool hasProperty (const std::string& name); + + private: + PropertyMap mProperties; + + protected: + PropertySetGet* mParent; + ///< the parent can provide properties as well (when they are retrieved via getProperty) \n + /// multiple levels of inheritance are also supported \n + /// children can override properties of their parents + + PropertySetGet* mContext; + ///< used to retrieve linked property values + }; + + template <typename T> + static T retrieveValue (boost::shared_ptr<PropertyValue>& value, PropertySetGet* context) + { + if (typeid(*value).name() == typeid(LinkedValue).name()) + { + std::string v = static_cast<LinkedValue*>(value.get())->get(context); + PropertyValuePtr newVal = PropertyValuePtr (new StringValue(v)); + return retrieveValue<T>(newVal, NULL); + } + if (typeid(T).name() == typeid(*value).name()) + { + // requested type is the same as source type, only have to cast it + return *static_cast<T*>(value.get()); + } + + if ((typeid(T).name() == typeid(StringValue).name()) + && typeid(*value).name() != typeid(StringValue).name()) + { + // if string type is requested and value is not string, use serialize method to convert to string + T* ptr = new T (value->serialize()); // note that T is always StringValue here, but we can't use it here + value = boost::shared_ptr<PropertyValue> (static_cast<PropertyValue*>(ptr)); + return *ptr; + } + + { + // remaining case: deserialization from string by passing the string to constructor of class T + T* ptr = new T(value->_getStringValue()); + PropertyValuePtr newVal (static_cast<PropertyValue*>(ptr)); + value = newVal; + return *ptr; + } + } + ///< + /// @brief alternate version that supports linked values (use of $variables in parent material) + /// @note \a value is changed in-place to the converted object + /// @return converted object \n + + /// Create a property from a string + inline PropertyValuePtr makeProperty (const std::string& prop) + { + if (prop.size() > 1 && prop[0] == '$') + return PropertyValuePtr (static_cast<PropertyValue*>(new LinkedValue(prop))); + else + return PropertyValuePtr (static_cast<PropertyValue*> (new StringValue(prop))); + } + + template <typename T> + /// Create a property of any type + /// Example: sh::makeProperty\<sh::Vector4\> (new sh::Vector4(1, 1, 1, 1)) + inline PropertyValuePtr makeProperty (T* p) + { + return PropertyValuePtr ( static_cast<PropertyValue*>(p) ); + } +} + +#endif diff --git a/extern/shiny/Main/ScriptLoader.cpp b/extern/shiny/Main/ScriptLoader.cpp new file mode 100644 index 0000000000..a8971dc87d --- /dev/null +++ b/extern/shiny/Main/ScriptLoader.cpp @@ -0,0 +1,401 @@ +#include "ScriptLoader.hpp" + +#include <vector> +#include <map> +#include <exception> +#include <fstream> + +#include <boost/filesystem.hpp> + +namespace sh +{ + void ScriptLoader::loadAllFiles(ScriptLoader* c, const std::string& path) + { + for ( boost::filesystem::recursive_directory_iterator end, dir(path); dir != end; ++dir ) + { + boost::filesystem::path p(*dir); + if(p.extension() == c->m_fileEnding) + { + c->m_currentFileName = (*dir).path().string(); + std::ifstream in((*dir).path().string().c_str(), std::ios::binary); + c->parseScript(in); + } + } + } + + ScriptLoader::ScriptLoader(const std::string& fileEnding) + { + m_fileEnding = fileEnding; + } + + ScriptLoader::~ScriptLoader() + { + clearScriptList(); + } + + void ScriptLoader::clearScriptList() + { + std::map <std::string, ScriptNode *>::iterator i; + for (i = m_scriptList.begin(); i != m_scriptList.end(); i++) + { + delete i->second; + } + m_scriptList.clear(); + } + + ScriptNode *ScriptLoader::getConfigScript(const std::string &name) + { + std::map <std::string, ScriptNode*>::iterator i; + + std::string key = name; + i = m_scriptList.find(key); + + //If found.. + if (i != m_scriptList.end()) + { + return i->second; + } + else + { + return NULL; + } + } + + std::map <std::string, ScriptNode*> ScriptLoader::getAllConfigScripts () + { + return m_scriptList; + } + + void ScriptLoader::parseScript(std::ifstream &stream) + { + //Get first token + _nextToken(stream); + if (tok == TOKEN_EOF) + { + stream.close(); + return; + } + + //Parse the script + _parseNodes(stream, 0); + + stream.close(); + } + + void ScriptLoader::_nextToken(std::ifstream &stream) + { + //EOF token + if (!stream.good()) + { + tok = TOKEN_EOF; + return; + } + + //(Get next character) + int ch = stream.get(); + + while ((ch == ' ' || ch == 9) && !stream.eof()) + { //Skip leading spaces / tabs + ch = stream.get(); + } + + if (!stream.good()) + { + tok = TOKEN_EOF; + return; + } + + //Newline token + if (ch == '\r' || ch == '\n') + { + do + { + ch = stream.get(); + } while ((ch == '\r' || ch == '\n') && !stream.eof()); + + stream.unget(); + + tok = TOKEN_NewLine; + return; + } + + //Open brace token + else if (ch == '{') + { + tok = TOKEN_OpenBrace; + return; + } + + //Close brace token + else if (ch == '}') + { + tok = TOKEN_CloseBrace; + return; + } + + //Text token + if (ch < 32 || ch > 122) //Verify valid char + { + throw std::runtime_error("Parse Error: Invalid character, ConfigLoader::load()"); + } + + tokVal = ""; + tok = TOKEN_Text; + do + { + //Skip comments + if (ch == '/') + { + int ch2 = stream.peek(); + + //C++ style comment (//) + if (ch2 == '/') + { + stream.get(); + do + { + ch = stream.get(); + } while (ch != '\r' && ch != '\n' && !stream.eof()); + + tok = TOKEN_NewLine; + return; + } + } + + //Add valid char to tokVal + tokVal += (char)ch; + + //Next char + ch = stream.get(); + + } while (ch > 32 && ch <= 122 && !stream.eof()); + + stream.unget(); + + return; + } + + void ScriptLoader::_skipNewLines(std::ifstream &stream) + { + while (tok == TOKEN_NewLine) + { + _nextToken(stream); + } + } + + void ScriptLoader::_parseNodes(std::ifstream &stream, ScriptNode *parent) + { + typedef std::pair<std::string, ScriptNode*> ScriptItem; + + while (true) + { + switch (tok) + { + //Node + case TOKEN_Text: + { + //Add the new node + ScriptNode *newNode; + if (parent) + { + newNode = parent->addChild(tokVal); + } + else + { + newNode = new ScriptNode(0, tokVal); + } + + //Get values + _nextToken(stream); + std::string valueStr; + int i=0; + while (tok == TOKEN_Text) + { + if (i == 0) + valueStr += tokVal; + else + valueStr += " " + tokVal; + _nextToken(stream); + ++i; + } + newNode->setValue(valueStr); + + //Add root nodes to scriptList + if (!parent) + { + std::string key; + + if (newNode->getValue() == "") + throw std::runtime_error("Root node must have a name (\"" + newNode->getName() + "\")"); + key = newNode->getValue(); + + m_scriptList.insert(ScriptItem(key, newNode)); + } + + _skipNewLines(stream); + + //Add any sub-nodes + if (tok == TOKEN_OpenBrace) + { + //Parse nodes + _nextToken(stream); + _parseNodes(stream, newNode); + //Check for matching closing brace + if (tok != TOKEN_CloseBrace) + { + throw std::runtime_error("Parse Error: Expecting closing brace"); + } + _nextToken(stream); + _skipNewLines(stream); + } + + newNode->m_fileName = m_currentFileName; + + break; + } + + //Out of place brace + case TOKEN_OpenBrace: + throw std::runtime_error("Parse Error: Opening brace out of plane"); + break; + + //Return if end of nodes have been reached + case TOKEN_CloseBrace: + return; + + //Return if reached end of file + case TOKEN_EOF: + return; + + case TOKEN_NewLine: + _nextToken(stream); + break; + } + }; + } + + ScriptNode::ScriptNode(ScriptNode *parent, const std::string &name) + { + m_name = name; + m_parent = parent; + _removeSelf = true; //For proper destruction + m_lastChildFound = -1; + + //Add self to parent's child list (unless this is the root node being created) + if (parent != NULL) + { + m_parent->m_children.push_back(this); + _iter = --(m_parent->m_children.end()); + } + } + + ScriptNode::~ScriptNode() + { + //Delete all children + std::vector<ScriptNode*>::iterator i; + for (i = m_children.begin(); i != m_children.end(); i++) + { + ScriptNode *node = *i; + node->_removeSelf = false; + delete node; + } + m_children.clear(); + + //Remove self from parent's child list + if (_removeSelf && m_parent != NULL) + { + m_parent->m_children.erase(_iter); + } + } + + ScriptNode *ScriptNode::addChild(const std::string &name, bool replaceExisting) + { + if (replaceExisting) + { + ScriptNode *node = findChild(name, false); + if (node) + { + return node; + } + } + return new ScriptNode(this, name); + } + + ScriptNode *ScriptNode::findChild(const std::string &name, bool recursive) + { + int indx, prevC, nextC; + int childCount = (int)m_children.size(); + + if (m_lastChildFound != -1) + { + //If possible, try checking the nodes neighboring the last successful search + //(often nodes searched for in sequence, so this will boost search speeds). + prevC = m_lastChildFound-1; if (prevC < 0) prevC = 0; else if (prevC >= childCount) prevC = childCount-1; + nextC = m_lastChildFound+1; if (nextC < 0) nextC = 0; else if (nextC >= childCount) nextC = childCount-1; + for (indx = prevC; indx <= nextC; ++indx) + { + ScriptNode *node = m_children[indx]; + if (node->m_name == name) + { + m_lastChildFound = indx; + return node; + } + } + + //If not found that way, search for the node from start to finish, avoiding the + //already searched area above. + for (indx = nextC + 1; indx < childCount; ++indx) + { + ScriptNode *node = m_children[indx]; + if (node->m_name == name) { + m_lastChildFound = indx; + return node; + } + } + for (indx = 0; indx < prevC; ++indx) + { + ScriptNode *node = m_children[indx]; + if (node->m_name == name) { + m_lastChildFound = indx; + return node; + } + } + } + else + { + //Search for the node from start to finish + for (indx = 0; indx < childCount; ++indx){ + ScriptNode *node = m_children[indx]; + if (node->m_name == name) { + m_lastChildFound = indx; + return node; + } + } + } + + //If not found, search child nodes (if recursive == true) + if (recursive) + { + for (indx = 0; indx < childCount; ++indx) + { + m_children[indx]->findChild(name, recursive); + } + } + + //Not found anywhere + return NULL; + } + + void ScriptNode::setParent(ScriptNode *newParent) + { + //Remove self from current parent + m_parent->m_children.erase(_iter); + + //Set new parent + m_parent = newParent; + + //Add self to new parent + m_parent->m_children.push_back(this); + _iter = --(m_parent->m_children.end()); + } +} diff --git a/extern/shiny/Main/ScriptLoader.hpp b/extern/shiny/Main/ScriptLoader.hpp new file mode 100644 index 0000000000..caf743bd22 --- /dev/null +++ b/extern/shiny/Main/ScriptLoader.hpp @@ -0,0 +1,134 @@ +#ifndef SH_CONFIG_LOADER_H__ +#define SH_CONFIG_LOADER_H__ + +#include <map> +#include <vector> +#include <cassert> +#include <string> + +namespace sh +{ + class ScriptNode; + + /** + * @brief The base class of loaders that read Ogre style script files to get configuration and settings. + * Heavily inspired by: http://www.ogre3d.org/tikiwiki/All-purpose+script+parser + * ( "Non-ogre version") + */ + class ScriptLoader + { + public: + static void loadAllFiles(ScriptLoader* c, const std::string& path); + + ScriptLoader(const std::string& fileEnding); + virtual ~ScriptLoader(); + + std::string m_fileEnding; + + // For a line like + // entity animals/dog + // { + // ... + // } + // The type is "entity" and the name is "animals/dog" + // Or if animal/dog was not there then name is "" + ScriptNode *getConfigScript (const std::string &name); + + std::map <std::string, ScriptNode*> getAllConfigScripts (); + + void parseScript(std::ifstream &stream); + + std::string m_currentFileName; + + protected: + + float m_LoadOrder; + // like "*.object" + + std::map <std::string, ScriptNode*> m_scriptList; + + enum Token + { + TOKEN_Text, + TOKEN_NewLine, + TOKEN_OpenBrace, + TOKEN_CloseBrace, + TOKEN_EOF + }; + + Token tok, lastTok; + std::string tokVal; + + void _parseNodes(std::ifstream &stream, ScriptNode *parent); + void _nextToken(std::ifstream &stream); + void _skipNewLines(std::ifstream &stream); + + void clearScriptList(); + }; + + class ScriptNode + { + public: + ScriptNode(ScriptNode *parent, const std::string &name = "untitled"); + ~ScriptNode(); + + inline void setName(const std::string &name) + { + this->m_name = name; + } + + inline std::string &getName() + { + return m_name; + } + + inline void setValue(const std::string &value) + { + m_value = value; + } + + inline std::string &getValue() + { + return m_value; + } + + ScriptNode *addChild(const std::string &name = "untitled", bool replaceExisting = false); + ScriptNode *findChild(const std::string &name, bool recursive = false); + + inline std::vector<ScriptNode*> &getChildren() + { + return m_children; + } + + inline ScriptNode *getChild(unsigned int index = 0) + { + assert(index < m_children.size()); + return m_children[index]; + } + + void setParent(ScriptNode *newParent); + + inline ScriptNode *getParent() + { + return m_parent; + } + + std::string m_fileName; + + + private: + std::string m_name; + std::string m_value; + std::vector<ScriptNode*> m_children; + ScriptNode *m_parent; + + + int m_lastChildFound; //The last child node's index found with a call to findChild() + + std::vector<ScriptNode*>::iterator _iter; + bool _removeSelf; + }; + +} + +#endif diff --git a/extern/shiny/Main/ShaderInstance.cpp b/extern/shiny/Main/ShaderInstance.cpp new file mode 100644 index 0000000000..07ef8dfe28 --- /dev/null +++ b/extern/shiny/Main/ShaderInstance.cpp @@ -0,0 +1,707 @@ +#include "ShaderInstance.hpp" + +#include <stdexcept> +#include <iostream> +#include <fstream> + +#include <boost/lexical_cast.hpp> +#include <boost/algorithm/string.hpp> +#include <boost/bind.hpp> + +#include <boost/filesystem.hpp> + +#include "Preprocessor.hpp" +#include "Factory.hpp" +#include "ShaderSet.hpp" + +namespace +{ + std::string convertLang (sh::Language lang) + { + if (lang == sh::Language_CG) + return "SH_CG"; + else if (lang == sh::Language_HLSL) + return "SH_HLSL"; + else //if (lang == sh::Language_GLSL) + return "SH_GLSL"; + } + + char getComponent(int num) + { + if (num == 0) + return 'x'; + else if (num == 1) + return 'y'; + else if (num == 2) + return 'z'; + else if (num == 3) + return 'w'; + else + throw std::runtime_error("invalid component"); + } + + std::string getFloat(sh::Language lang, int num_components) + { + if (lang == sh::Language_CG || lang == sh::Language_HLSL) + return (num_components == 1) ? "float" : "float" + boost::lexical_cast<std::string>(num_components); + else + return (num_components == 1) ? "float" : "vec" + boost::lexical_cast<std::string>(num_components); + } + + bool isCmd (const std::string& source, size_t pos, const std::string& cmd) + { + return (source.size() >= pos + cmd.size() && source.substr(pos, cmd.size()) == cmd); + } + + void writeDebugFile (const std::string& content, const std::string& filename) + { + boost::filesystem::path full_path(boost::filesystem::current_path()); + std::ofstream of ((full_path / filename ).string().c_str() , std::ios_base::out); + of.write(content.c_str(), content.size()); + of.close(); + } +} + +namespace sh +{ + std::string Passthrough::expand_assign(std::string toAssign) + { + std::string res; + + int i = 0; + int current_passthrough = passthrough_number; + int current_component_left = component_start; + int current_component_right = 0; + int components_left = num_components; + int components_at_once; + while (i < num_components) + { + if (components_left + current_component_left <= 4) + components_at_once = components_left; + else + components_at_once = 4 - current_component_left; + + std::string componentStr = "."; + for (int j = 0; j < components_at_once; ++j) + componentStr += getComponent(j + current_component_left); + std::string componentStr2 = "."; + for (int j = 0; j < components_at_once; ++j) + componentStr2 += getComponent(j + current_component_right); + if (num_components == 1) + { + componentStr2 = ""; + } + res += "passthrough" + boost::lexical_cast<std::string>(current_passthrough) + componentStr + " = " + toAssign + componentStr2; + + current_component_left += components_at_once; + current_component_right += components_at_once; + components_left -= components_at_once; + + i += components_at_once; + + if (components_left == 0) + { + // finished + return res; + } + else + { + // add semicolon to every instruction but the last + res += "; "; + } + + if (current_component_left == 4) + { + current_passthrough++; + current_component_left = 0; + } + } + throw std::runtime_error("expand_assign error"); // this should never happen, but gets us rid of the "control reaches end of non-void function" warning + } + + std::string Passthrough::expand_receive() + { + std::string res; + + res += getFloat(lang, num_components) + "("; + + int i = 0; + int current_passthrough = passthrough_number; + int current_component = component_start; + int components_left = num_components; + while (i < num_components) + { + int components_at_once = std::min(components_left, 4 - current_component); + + std::string componentStr; + for (int j = 0; j < components_at_once; ++j) + componentStr += getComponent(j + current_component); + + res += "passthrough" + boost::lexical_cast<std::string>(current_passthrough) + "." + componentStr; + + current_component += components_at_once; + + components_left -= components_at_once; + + i += components_at_once; + + if (components_left == 0) + { + // finished + return res + ")"; +; + } + else + { + // add comma to every variable but the last + res += ", "; + } + + if (current_component == 4) + { + current_passthrough++; + current_component = 0; + } + } + + throw std::runtime_error("expand_receive error"); // this should never happen, but gets us rid of the "control reaches end of non-void function" warning + } + + // ------------------------------------------------------------------------------ + + void ShaderInstance::parse (std::string& source, PropertySetGet* properties) + { + size_t pos = 0; + while (true) + { + pos = source.find("@", pos); + if (pos == std::string::npos) + break; + + if (isCmd(source, pos, "@shProperty")) + { + std::vector<std::string> args = extractMacroArguments (pos, source); + + size_t start = source.find("(", pos); + size_t end = source.find(")", pos); + std::string cmd = source.substr(pos+1, start-(pos+1)); + + std::string replaceValue; + if (cmd == "shPropertyBool") + { + std::string propertyName = args[0]; + PropertyValuePtr value = properties->getProperty(propertyName); + bool val = retrieveValue<BooleanValue>(value, properties->getContext()).get(); + replaceValue = val ? "1" : "0"; + } + else if (cmd == "shPropertyNotBool") // same as above, but inverts the result + { + std::string propertyName = args[0]; + PropertyValuePtr value = properties->getProperty(propertyName); + bool val = retrieveValue<BooleanValue>(value, properties->getContext()).get(); + replaceValue = val ? "0" : "1"; + } + else if (cmd == "shPropertyString") + { + std::string propertyName = args[0]; + PropertyValuePtr value = properties->getProperty(propertyName); + replaceValue = retrieveValue<StringValue>(value, properties->getContext()).get(); + } + else if (cmd == "shPropertyEqual") + { + std::string propertyName = args[0]; + std::string comparedAgainst = args[1]; + std::string value = retrieveValue<StringValue>(properties->getProperty(propertyName), properties->getContext()).get(); + replaceValue = (value == comparedAgainst) ? "1" : "0"; + } + else + throw std::runtime_error ("unknown command \"" + cmd + "\""); + source.replace(pos, (end+1)-pos, replaceValue); + } + else if (isCmd(source, pos, "@shGlobalSetting")) + { + std::vector<std::string> args = extractMacroArguments (pos, source); + + std::string cmd = source.substr(pos+1, source.find("(", pos)-(pos+1)); + std::string replaceValue; + if (cmd == "shGlobalSettingBool") + { + std::string settingName = args[0]; + std::string value = retrieveValue<StringValue>(mParent->getCurrentGlobalSettings()->getProperty(settingName), NULL).get(); + replaceValue = (value == "true" || value == "1") ? "1" : "0"; + } + else if (cmd == "shGlobalSettingEqual") + { + std::string settingName = args[0]; + std::string comparedAgainst = args[1]; + std::string value = retrieveValue<StringValue>(mParent->getCurrentGlobalSettings()->getProperty(settingName), NULL).get(); + replaceValue = (value == comparedAgainst) ? "1" : "0"; + } + else if (cmd == "shGlobalSettingString") + { + std::string settingName = args[0]; + replaceValue = retrieveValue<StringValue>(mParent->getCurrentGlobalSettings()->getProperty(settingName), NULL).get(); + } + else + throw std::runtime_error ("unknown command \"" + cmd + "\""); + + source.replace(pos, (source.find(")", pos)+1)-pos, replaceValue); + } + else if (isCmd(source, pos, "@shForeach")) + { + + assert(source.find("@shEndForeach", pos) != std::string::npos); + size_t block_end = source.find("@shEndForeach", pos); + + // get the argument for parsing + size_t start = source.find("(", pos); + size_t end = start; + int brace_depth = 1; + while (brace_depth > 0) + { + ++end; + if (source[end] == '(') + ++brace_depth; + else if (source[end] == ')') + --brace_depth; + } + std::string arg = source.substr(start+1, end-(start+1)); + parse(arg, properties); + + int num = boost::lexical_cast<int>(arg); + + // get the content of the inner block + std::string content = source.substr(end+1, block_end - (end+1)); + + // replace both outer and inner block with content of inner block num times + std::string replaceStr; + for (int i=0; i<num; ++i) + { + // replace @shIterator with the current iteration + std::string addStr = content; + + while (true) + { + size_t pos2 = addStr.find("@shIterator"); + if (pos2 == std::string::npos) + break; + + // optional offset parameter. + size_t openBracePos = pos2 + std::string("@shIterator").length(); + if (addStr[openBracePos] == '(') + { + // get the argument for parsing + size_t _start = openBracePos; + size_t _end = _start; + int _brace_depth = 1; + while (_brace_depth > 0) + { + ++_end; + if (addStr[_end] == '(') + ++_brace_depth; + else if (addStr[_end] == ')') + --_brace_depth; + } + std::string arg = addStr.substr(_start+1, _end-(_start+1)); + parse(arg, properties); + + int offset = boost::lexical_cast<int> (arg); + addStr.replace(pos2, (_end+1)-pos2, boost::lexical_cast<std::string>(i+offset)); + } + else + { + addStr.replace(pos2, std::string("@shIterator").length(), boost::lexical_cast<std::string>(i)); + } + } + + replaceStr += addStr; + } + source.replace(pos, (block_end+std::string("@shEndForeach").length())-pos, replaceStr); + } + else if (source.size() > pos+1) + ++pos; // skip + } + + } + + ShaderInstance::ShaderInstance (ShaderSet* parent, const std::string& name, PropertySetGet* properties) + : mName(name) + , mParent(parent) + , mSupported(true) + , mCurrentPassthrough(0) + , mCurrentComponent(0) + { + std::string source = mParent->getSource(); + int type = mParent->getType(); + std::string basePath = mParent->getBasePath(); + size_t pos; + + bool readCache = Factory::getInstance ().getReadSourceCache () && boost::filesystem::exists( + Factory::getInstance ().getCacheFolder () + "/" + mName) + && !mParent->isDirty (); + bool writeCache = Factory::getInstance ().getWriteSourceCache (); + + + if (readCache) + { + std::ifstream ifs( std::string(Factory::getInstance ().getCacheFolder () + "/" + mName).c_str() ); + std::stringstream ss; + ss << ifs.rdbuf(); + source = ss.str(); + } + else + { + std::vector<std::string> definitions; + + if (mParent->getType() == GPT_Vertex) + definitions.push_back("SH_VERTEX_SHADER"); + else + definitions.push_back("SH_FRAGMENT_SHADER"); + definitions.push_back(convertLang(Factory::getInstance().getCurrentLanguage())); + + parse(source, properties); + + if (Factory::getInstance ().getShaderDebugOutputEnabled ()) + writeDebugFile(source, name + ".pre"); + else + { + #ifdef SHINY_WRITE_SHADER_DEBUG + writeDebugFile(source, name + ".pre"); + #endif + } + + // why do we need our own preprocessor? there are several custom commands available in the shader files + // (for example for binding uniforms to properties or auto constants) - more below. it is important that these + // commands are _only executed if the specific code path actually "survives" the compilation. + // thus, we run the code through a preprocessor first to remove the parts that are unused because of + // unmet #if conditions (or other preprocessor directives). + source = Preprocessor::preprocess(source, basePath, definitions, name); + + // parse counter + std::map<int, int> counters; + while (true) + { + pos = source.find("@shCounter"); + if (pos == std::string::npos) + break; + + size_t end = source.find(")", pos); + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size()); + + int index = boost::lexical_cast<int>(args[0]); + + if (counters.find(index) == counters.end()) + counters[index] = 0; + + source.replace(pos, (end+1)-pos, boost::lexical_cast<std::string>(counters[index]++)); + } + + // parse passthrough declarations + while (true) + { + pos = source.find("@shAllocatePassthrough"); + if (pos == std::string::npos) + break; + + if (mCurrentPassthrough > 7) + throw std::runtime_error ("too many passthrough's requested (max 8)"); + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size() == 2); + + size_t end = source.find(")", pos); + + Passthrough passthrough; + + passthrough.num_components = boost::lexical_cast<int>(args[0]); + assert (passthrough.num_components != 0); + + std::string passthroughName = args[1]; + passthrough.lang = Factory::getInstance().getCurrentLanguage (); + passthrough.component_start = mCurrentComponent; + passthrough.passthrough_number = mCurrentPassthrough; + + mPassthroughMap[passthroughName] = passthrough; + + mCurrentComponent += passthrough.num_components; + if (mCurrentComponent > 3) + { + mCurrentComponent -= 4; + ++mCurrentPassthrough; + } + + source.erase(pos, (end+1)-pos); + } + + // passthrough assign + while (true) + { + pos = source.find("@shPassthroughAssign"); + if (pos == std::string::npos) + break; + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size() == 2); + + size_t end = source.find(")", pos); + + std::string passthroughName = args[0]; + std::string assignTo = args[1]; + + assert(mPassthroughMap.find(passthroughName) != mPassthroughMap.end()); + Passthrough& p = mPassthroughMap[passthroughName]; + + source.replace(pos, (end+1)-pos, p.expand_assign(assignTo)); + } + + // passthrough receive + while (true) + { + pos = source.find("@shPassthroughReceive"); + if (pos == std::string::npos) + break; + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size() == 1); + + size_t end = source.find(")", pos); + std::string passthroughName = args[0]; + + assert(mPassthroughMap.find(passthroughName) != mPassthroughMap.end()); + Passthrough& p = mPassthroughMap[passthroughName]; + + source.replace(pos, (end+1)-pos, p.expand_receive()); + } + + // passthrough vertex outputs + while (true) + { + pos = source.find("@shPassthroughVertexOutputs"); + if (pos == std::string::npos) + break; + + std::string result; + for (int i = 0; i < mCurrentPassthrough+1; ++i) + { + // not using newlines here, otherwise the line numbers reported by compiler would be messed up.. + if (Factory::getInstance().getCurrentLanguage () == Language_CG || Factory::getInstance().getCurrentLanguage () == Language_HLSL) + result += ", out float4 passthrough" + boost::lexical_cast<std::string>(i) + " : TEXCOORD" + boost::lexical_cast<std::string>(i); + + /* + else + result += "out vec4 passthrough" + boost::lexical_cast<std::string>(i) + "; "; + */ + else + result += "varying vec4 passthrough" + boost::lexical_cast<std::string>(i) + "; "; + } + + source.replace(pos, std::string("@shPassthroughVertexOutputs").length(), result); + } + + // passthrough fragment inputs + while (true) + { + pos = source.find("@shPassthroughFragmentInputs"); + if (pos == std::string::npos) + break; + + std::string result; + for (int i = 0; i < mCurrentPassthrough+1; ++i) + { + // not using newlines here, otherwise the line numbers reported by compiler would be messed up.. + if (Factory::getInstance().getCurrentLanguage () == Language_CG || Factory::getInstance().getCurrentLanguage () == Language_HLSL) + result += ", in float4 passthrough" + boost::lexical_cast<std::string>(i) + " : TEXCOORD" + boost::lexical_cast<std::string>(i); + /* + else + result += "in vec4 passthrough" + boost::lexical_cast<std::string>(i) + "; "; + */ + else + result += "varying vec4 passthrough" + boost::lexical_cast<std::string>(i) + "; "; + } + + source.replace(pos, std::string("@shPassthroughFragmentInputs").length(), result); + } + } + + // save to cache _here_ - we want to preserve some macros + if (writeCache && !readCache) + { + std::ofstream of (std::string(Factory::getInstance ().getCacheFolder () + "/" + mName).c_str(), std::ios_base::out); + of.write(source.c_str(), source.size()); + of.close(); + } + + + // parse shared parameters + while (true) + { + pos = source.find("@shSharedParameter"); + if (pos == std::string::npos) + break; + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size()); + + size_t end = source.find(")", pos); + + mSharedParameters.push_back(args[0]); + + source.erase(pos, (end+1)-pos); + } + + // parse auto constants + typedef std::map< std::string, std::pair<std::string, std::string> > AutoConstantMap; + AutoConstantMap autoConstants; + while (true) + { + pos = source.find("@shAutoConstant"); + if (pos == std::string::npos) + break; + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size() >= 2); + + size_t end = source.find(")", pos); + + std::string autoConstantName, uniformName; + std::string extraData; + + uniformName = args[0]; + autoConstantName = args[1]; + if (args.size() > 2) + extraData = args[2]; + + autoConstants[uniformName] = std::make_pair(autoConstantName, extraData); + + source.erase(pos, (end+1)-pos); + } + + // parse uniform properties + while (true) + { + pos = source.find("@shUniformProperty"); + if (pos == std::string::npos) + break; + + std::vector<std::string> args = extractMacroArguments (pos, source); + assert(args.size() == 2); + + size_t start = source.find("(", pos); + size_t end = source.find(")", pos); + std::string cmd = source.substr(pos, start-pos); + + ValueType vt; + if (cmd == "@shUniformProperty4f") + vt = VT_Vector4; + else if (cmd == "@shUniformProperty3f") + vt = VT_Vector3; + else if (cmd == "@shUniformProperty2f") + vt = VT_Vector2; + else if (cmd == "@shUniformProperty1f") + vt = VT_Float; + else if (cmd == "@shUniformPropertyInt") + vt = VT_Int; + else + throw std::runtime_error ("unsupported command \"" + cmd + "\""); + + + std::string propertyName, uniformName; + uniformName = args[0]; + propertyName = args[1]; + mUniformProperties[uniformName] = std::make_pair(propertyName, vt); + + source.erase(pos, (end+1)-pos); + } + + // parse texture samplers used + while (true) + { + pos = source.find("@shUseSampler"); + if (pos == std::string::npos) + break; + + size_t end = source.find(")", pos); + + mUsedSamplers.push_back(extractMacroArguments (pos, source)[0]); + source.erase(pos, (end+1)-pos); + } + + // convert any left-over @'s to # + boost::algorithm::replace_all(source, "@", "#"); + + Platform* platform = Factory::getInstance().getPlatform(); + + std::string profile; + if (Factory::getInstance ().getCurrentLanguage () == Language_CG) + profile = mParent->getCgProfile (); + else if (Factory::getInstance ().getCurrentLanguage () == Language_HLSL) + profile = mParent->getHlslProfile (); + + + if (type == GPT_Vertex) + mProgram = boost::shared_ptr<GpuProgram>(platform->createGpuProgram(GPT_Vertex, "", mName, profile, source, Factory::getInstance().getCurrentLanguage())); + else if (type == GPT_Fragment) + mProgram = boost::shared_ptr<GpuProgram>(platform->createGpuProgram(GPT_Fragment, "", mName, profile, source, Factory::getInstance().getCurrentLanguage())); + + + if (Factory::getInstance ().getShaderDebugOutputEnabled ()) + writeDebugFile(source, name); + else + { +#ifdef SHINY_WRITE_SHADER_DEBUG + writeDebugFile(source, name); +#endif + } + + if (!mProgram->getSupported()) + { + std::cerr << " Full source code below: \n" << source << std::endl; + mSupported = false; + return; + } + + // set auto constants + for (AutoConstantMap::iterator it = autoConstants.begin(); it != autoConstants.end(); ++it) + { + mProgram->setAutoConstant(it->first, it->second.first, it->second.second); + } + } + + std::string ShaderInstance::getName () + { + return mName; + } + + bool ShaderInstance::getSupported () const + { + return mSupported; + } + + std::vector<std::string> ShaderInstance::getUsedSamplers() + { + return mUsedSamplers; + } + + void ShaderInstance::setUniformParameters (boost::shared_ptr<Pass> pass, PropertySetGet* properties) + { + for (UniformMap::iterator it = mUniformProperties.begin(); it != mUniformProperties.end(); ++it) + { + pass->setGpuConstant(mParent->getType(), it->first, it->second.second, properties->getProperty(it->second.first), properties->getContext()); + } + } + + std::vector<std::string> ShaderInstance::extractMacroArguments (size_t pos, const std::string& source) + { + size_t start = source.find("(", pos); + size_t end = source.find(")", pos); + std::string args = source.substr(start+1, end-(start+1)); + std::vector<std::string> results; + boost::algorithm::split(results, args, boost::is_any_of(",")); + std::for_each(results.begin(), results.end(), + boost::bind(&boost::trim<std::string>, + _1, std::locale() )); + return results; + } +} diff --git a/extern/shiny/Main/ShaderInstance.hpp b/extern/shiny/Main/ShaderInstance.hpp new file mode 100644 index 0000000000..76326ce0c3 --- /dev/null +++ b/extern/shiny/Main/ShaderInstance.hpp @@ -0,0 +1,71 @@ +#ifndef SH_SHADERINSTANCE_H +#define SH_SHADERINSTANCE_H + +#include <vector> + +#include "Platform.hpp" + +namespace sh +{ + class ShaderSet; + + typedef std::map< std::string, std::pair<std::string, ValueType > > UniformMap; + + struct Passthrough + { + Language lang; ///< language to generate for + + int num_components; ///< e.g. 4 for a float4 + + int passthrough_number; + int component_start; ///< 0 = x + + std::string expand_assign(std::string assignTo); + std::string expand_receive(); + }; + typedef std::map<std::string, Passthrough> PassthroughMap; + + /** + * @brief A specific instance of a \a ShaderSet with a deterministic shader source + */ + class ShaderInstance + { + public: + ShaderInstance (ShaderSet* parent, const std::string& name, PropertySetGet* properties); + + std::string getName(); + + bool getSupported () const; + + std::vector<std::string> getUsedSamplers(); + std::vector<std::string> getSharedParameters() { return mSharedParameters; } + + void setUniformParameters (boost::shared_ptr<Pass> pass, PropertySetGet* properties); + + private: + boost::shared_ptr<GpuProgram> mProgram; + std::string mName; + ShaderSet* mParent; + bool mSupported; ///< shader compilation was sucessful? + + std::vector<std::string> mUsedSamplers; + ///< names of the texture samplers that are used by this shader + + std::vector<std::string> mSharedParameters; + + UniformMap mUniformProperties; + ///< uniforms that this depends on, and their property names / value-types + /// @note this lists shared uniform parameters as well + + int mCurrentPassthrough; ///< 0 - x + int mCurrentComponent; ///< 0:x, 1:y, 2:z, 3:w + + PassthroughMap mPassthroughMap; + + std::vector<std::string> extractMacroArguments (size_t pos, const std::string& source); ///< take a macro invocation and return vector of arguments + + void parse (std::string& source, PropertySetGet* properties); + }; +} + +#endif diff --git a/extern/shiny/Main/ShaderSet.cpp b/extern/shiny/Main/ShaderSet.cpp new file mode 100644 index 0000000000..2702ece194 --- /dev/null +++ b/extern/shiny/Main/ShaderSet.cpp @@ -0,0 +1,172 @@ +#include "ShaderSet.hpp" + +#include <fstream> +#include <sstream> + +#include <boost/algorithm/string/predicate.hpp> +#include <boost/functional/hash.hpp> +#include <boost/lexical_cast.hpp> + +#include "Factory.hpp" + +namespace sh +{ + ShaderSet::ShaderSet (const std::string& type, const std::string& cgProfile, const std::string& hlslProfile, const std::string& sourceFile, const std::string& basePath, + const std::string& name, PropertySetGet* globalSettingsPtr) + : mBasePath(basePath) + , mName(name) + , mCgProfile(cgProfile) + , mHlslProfile(hlslProfile) + , mIsDirty(false) + { + if (type == "vertex") + mType = GPT_Vertex; + else // if (type == "fragment") + mType = GPT_Fragment; + + std::ifstream stream(sourceFile.c_str(), std::ifstream::in); + std::stringstream buffer; + + buffer << stream.rdbuf(); + stream.close(); + mSource = buffer.str(); + parse(); + } + + void ShaderSet::parse() + { + std::string currentToken; + bool tokenIsRecognized = false; + bool isInBraces = false; + for (std::string::const_iterator it = mSource.begin(); it != mSource.end(); ++it) + { + char c = *it; + if (((c == ' ') && !isInBraces) || (c == '\n') || + ( ((c == '(') || (c == ')')) + && !tokenIsRecognized)) + { + if (tokenIsRecognized) + { + if (boost::starts_with(currentToken, "@shGlobalSetting")) + { + assert ((currentToken.find('(') != std::string::npos) && (currentToken.find(')') != std::string::npos)); + size_t start = currentToken.find('(')+1; + mGlobalSettings.push_back(currentToken.substr(start, currentToken.find(')')-start)); + } + else if (boost::starts_with(currentToken, "@shPropertyEqual")) + { + assert ((currentToken.find('(') != std::string::npos) && (currentToken.find(')') != std::string::npos) + && (currentToken.find(',') != std::string::npos)); + size_t start = currentToken.find('(')+1; + size_t end = currentToken.find(','); + mProperties.push_back(currentToken.substr(start, end-start)); + } + else if (boost::starts_with(currentToken, "@shProperty")) + { + assert ((currentToken.find('(') != std::string::npos) && (currentToken.find(')') != std::string::npos)); + size_t start = currentToken.find('(')+1; + std::string propertyName = currentToken.substr(start, currentToken.find(')')-start); + // if the property name is constructed dynamically (e.g. through an iterator) then there is nothing we can do + if (propertyName.find("@") == std::string::npos) + mProperties.push_back(propertyName); + } + } + + currentToken = ""; + } + else + { + if (currentToken == "") + { + if (c == '@') + tokenIsRecognized = true; + else + tokenIsRecognized = false; + } + else + { + if (c == '@') + { + // ouch, there are nested macros + // ( for example @shForeach(@shPropertyString(foobar)) ) + currentToken = ""; + } + } + + if (c == '(' && tokenIsRecognized) + isInBraces = true; + else if (c == ')' && tokenIsRecognized) + isInBraces = false; + + currentToken += c; + + } + } + } + + ShaderInstance* ShaderSet::getInstance (PropertySetGet* properties) + { + size_t h = buildHash (properties); + if (std::find(mFailedToCompile.begin(), mFailedToCompile.end(), h) != mFailedToCompile.end()) + return NULL; + if (mInstances.find(h) == mInstances.end()) + { + ShaderInstance newInstance(this, mName + "_" + boost::lexical_cast<std::string>(h), properties); + if (!newInstance.getSupported()) + { + mFailedToCompile.push_back(h); + return NULL; + } + mInstances.insert(std::make_pair(h, newInstance)); + } + return &mInstances.find(h)->second; + } + + size_t ShaderSet::buildHash (PropertySetGet* properties) + { + size_t seed = 0; + PropertySetGet* currentGlobalSettings = getCurrentGlobalSettings (); + + for (std::vector<std::string>::iterator it = mProperties.begin(); it != mProperties.end(); ++it) + { + std::string v = retrieveValue<StringValue>(properties->getProperty(*it), properties->getContext()).get(); + boost::hash_combine(seed, v); + } + for (std::vector <std::string>::iterator it = mGlobalSettings.begin(); it != mGlobalSettings.end(); ++it) + { + boost::hash_combine(seed, retrieveValue<StringValue>(currentGlobalSettings->getProperty(*it), NULL).get()); + } + boost::hash_combine(seed, static_cast<int>(Factory::getInstance().getCurrentLanguage())); + return seed; + } + + PropertySetGet* ShaderSet::getCurrentGlobalSettings() const + { + return Factory::getInstance ().getCurrentGlobalSettings (); + } + + std::string ShaderSet::getBasePath() const + { + return mBasePath; + } + + std::string ShaderSet::getSource() const + { + return mSource; + } + + std::string ShaderSet::getCgProfile() const + { + return mCgProfile; + } + + std::string ShaderSet::getHlslProfile() const + { + return mHlslProfile; + } + + int ShaderSet::getType() const + { + return mType; + } +} diff --git a/extern/shiny/Main/ShaderSet.hpp b/extern/shiny/Main/ShaderSet.hpp new file mode 100644 index 0000000000..776750598a --- /dev/null +++ b/extern/shiny/Main/ShaderSet.hpp @@ -0,0 +1,71 @@ +#ifndef SH_SHADERSET_H +#define SH_SHADERSET_H + +#include <string> +#include <vector> +#include <map> + +#include "ShaderInstance.hpp" + +namespace sh +{ + class PropertySetGet; + + typedef std::map<size_t, ShaderInstance> ShaderInstanceMap; + + /** + * @brief Contains possible shader permutations of a single uber-shader (represented by one source file) + */ + class ShaderSet + { + public: + ShaderSet (const std::string& type, const std::string& cgProfile, const std::string& hlslProfile, const std::string& sourceFile, const std::string& basePath, + const std::string& name, PropertySetGet* globalSettingsPtr); + + /// Retrieve a shader instance for the given properties. \n + /// If a \a ShaderInstance with the same properties exists already, simply returns this instance. \n + /// Otherwise, creates a new \a ShaderInstance (i.e. compiles a new shader). \n + /// Might also return NULL if the shader failed to compile. \n + /// @note Only the properties that actually affect the shader source are taken into consideration here, + /// so it does not matter if you pass any extra properties that the shader does not care about. + ShaderInstance* getInstance (PropertySetGet* properties); + + void markDirty() { mIsDirty = true; } + ///< Signals that the cache is out of date, and thus should not be used this time + + private: + PropertySetGet* getCurrentGlobalSettings() const; + std::string getBasePath() const; + std::string getSource() const; + std::string getCgProfile() const; + std::string getHlslProfile() const; + int getType() const; + + bool isDirty() { return mIsDirty; } + + friend class ShaderInstance; + + bool mIsDirty; + + private: + GpuProgramType mType; + std::string mSource; + std::string mBasePath; + std::string mCgProfile; + std::string mHlslProfile; + std::string mName; + + std::vector <size_t> mFailedToCompile; + + std::vector <std::string> mGlobalSettings; ///< names of the global settings that affect the shader source + std::vector <std::string> mProperties; ///< names of the per-material properties that affect the shader source + + ShaderInstanceMap mInstances; ///< maps permutation ID (generated from the properties) to \a ShaderInstance + + void parse(); ///< find out which properties and global settings affect the shader source + + size_t buildHash (PropertySetGet* properties); + }; +} + +#endif diff --git a/extern/shiny/Platforms/Ogre/OgreGpuProgram.cpp b/extern/shiny/Platforms/Ogre/OgreGpuProgram.cpp new file mode 100644 index 0000000000..fe5aa2fe77 --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreGpuProgram.cpp @@ -0,0 +1,70 @@ +#include <stdexcept> + +#include "OgreGpuProgram.hpp" + +#include <boost/lexical_cast.hpp> + +#include <OgreHighLevelGpuProgramManager.h> +#include <OgreGpuProgramManager.h> +#include <OgreVector4.h> + +namespace sh +{ + OgreGpuProgram::OgreGpuProgram( + GpuProgramType type, + const std::string& compileArguments, + const std::string& name, const std::string& profile, + const std::string& source, const std::string& lang, + const std::string& resourceGroup) + : GpuProgram() + { + Ogre::HighLevelGpuProgramManager& mgr = Ogre::HighLevelGpuProgramManager::getSingleton(); + assert (mgr.getByName(name).isNull() && "Vertex program already exists"); + + Ogre::GpuProgramType t; + if (type == GPT_Vertex) + t = Ogre::GPT_VERTEX_PROGRAM; + else + t = Ogre::GPT_FRAGMENT_PROGRAM; + + mProgram = mgr.createProgram(name, resourceGroup, lang, t); + if (lang != "glsl") + mProgram->setParameter("entry_point", "main"); + + if (lang == "hlsl") + mProgram->setParameter("target", profile); + else if (lang == "cg") + mProgram->setParameter("profiles", profile); + + mProgram->setSource(source); + mProgram->load(); + + if (mProgram.isNull() || !mProgram->isSupported()) + std::cerr << "Failed to compile shader \"" << name << "\". Consider the OGRE log for more information." << std::endl; + } + + bool OgreGpuProgram::getSupported() + { + return (!mProgram.isNull() && mProgram->isSupported()); + } + + void OgreGpuProgram::setAutoConstant (const std::string& name, const std::string& autoConstantName, const std::string& extraInfo) + { + assert (!mProgram.isNull() && mProgram->isSupported()); + const Ogre::GpuProgramParameters::AutoConstantDefinition* d = Ogre::GpuProgramParameters::getAutoConstantDefinition(autoConstantName); + + if (!d) + throw std::runtime_error ("can't find auto constant with name \"" + autoConstantName + "\""); + Ogre::GpuProgramParameters::AutoConstantType t = d->acType; + + // this simplifies debugging for CG a lot. + mProgram->getDefaultParameters()->setIgnoreMissingParams(true); + + if (d->dataType == Ogre::GpuProgramParameters::ACDT_NONE) + mProgram->getDefaultParameters()->setNamedAutoConstant (name, t, 0); + else if (d->dataType == Ogre::GpuProgramParameters::ACDT_INT) + mProgram->getDefaultParameters()->setNamedAutoConstant (name, t, extraInfo == "" ? 0 : boost::lexical_cast<int>(extraInfo)); + else if (d->dataType == Ogre::GpuProgramParameters::ACDT_REAL) + mProgram->getDefaultParameters()->setNamedAutoConstantReal (name, t, extraInfo == "" ? 0.f : boost::lexical_cast<float>(extraInfo)); + } +} diff --git a/extern/shiny/Platforms/Ogre/OgreGpuProgram.hpp b/extern/shiny/Platforms/Ogre/OgreGpuProgram.hpp new file mode 100644 index 0000000000..42673ed9b4 --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreGpuProgram.hpp @@ -0,0 +1,31 @@ +#ifndef SH_OGREGPUPROGRAM_H +#define SH_OGREGPUPROGRAM_H + +#include <string> + +#include <OgreHighLevelGpuProgram.h> + +#include "../../Main/Platform.hpp" + +namespace sh +{ + class OgreGpuProgram : public GpuProgram + { + public: + OgreGpuProgram ( + GpuProgramType type, + const std::string& compileArguments, + const std::string& name, const std::string& profile, + const std::string& source, const std::string& lang, + const std::string& resourceGroup); + + virtual bool getSupported(); + + virtual void setAutoConstant (const std::string& name, const std::string& autoConstantName, const std::string& extraInfo = ""); + + private: + Ogre::HighLevelGpuProgramPtr mProgram; + }; +} + +#endif diff --git a/extern/shiny/Platforms/Ogre/OgreMaterial.cpp b/extern/shiny/Platforms/Ogre/OgreMaterial.cpp new file mode 100644 index 0000000000..4a550b8bff --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreMaterial.cpp @@ -0,0 +1,99 @@ +#include "OgreMaterial.hpp" + +#include <OgreMaterialManager.h> +#include <OgreTechnique.h> +#include <stdexcept> + +#include "OgrePass.hpp" +#include "OgreMaterialSerializer.hpp" +#include "OgrePlatform.hpp" + +namespace sh +{ + static const std::string sDefaultTechniqueName = "SH_DefaultTechnique"; + + OgreMaterial::OgreMaterial (const std::string& name, const std::string& resourceGroup) + : Material() + { + assert (Ogre::MaterialManager::getSingleton().getByName(name).isNull() && "Material already exists"); + mMaterial = Ogre::MaterialManager::getSingleton().create (name, resourceGroup); + mMaterial->removeAllTechniques(); + mMaterial->createTechnique()->setSchemeName (sDefaultTechniqueName); + mMaterial->compile(); + } + + OgreMaterial::~OgreMaterial() + { + Ogre::MaterialManager::getSingleton().remove(mMaterial->getName()); + } + + boost::shared_ptr<Pass> OgreMaterial::createPass (const std::string& configuration, unsigned short lodIndex) + { + return boost::shared_ptr<Pass> (new OgrePass (this, configuration, lodIndex)); + } + + void OgreMaterial::removeAll () + { + mMaterial->removeAllTechniques(); + mMaterial->createTechnique()->setSchemeName (sDefaultTechniqueName); + mMaterial->compile(); + } + + void OgreMaterial::setLodLevels (const std::string& lodLevels) + { + OgreMaterialSerializer& s = OgrePlatform::getSerializer(); + + s.setMaterialProperty ("lod_values", lodLevels, mMaterial); + } + + bool OgreMaterial::createConfiguration (const std::string& name, unsigned short lodIndex) + { + for (int i=0; i<mMaterial->getNumTechniques(); ++i) + { + if (mMaterial->getTechnique(i)->getSchemeName() == name && mMaterial->getTechnique(i)->getLodIndex() == lodIndex) + return false; + } + + Ogre::Technique* t = mMaterial->createTechnique(); + t->setSchemeName (name); + t->setLodIndex (lodIndex); + if (mShadowCasterMaterial != "") + t->setShadowCasterMaterial(mShadowCasterMaterial); + + mMaterial->compile(); + + return true; + } + + Ogre::MaterialPtr OgreMaterial::getOgreMaterial () + { + return mMaterial; + } + + Ogre::Technique* OgreMaterial::getOgreTechniqueForConfiguration (const std::string& configurationName, unsigned short lodIndex) + { + for (int i=0; i<mMaterial->getNumTechniques(); ++i) + { + if (mMaterial->getTechnique(i)->getSchemeName() == configurationName && mMaterial->getTechnique(i)->getLodIndex() == lodIndex) + { + return mMaterial->getTechnique(i); + } + } + + // Prepare and throw error message + std::stringstream message; + message << "Could not find configurationName '" << configurationName + << "' and lodIndex " << lodIndex; + + throw std::runtime_error(message.str()); + } + + void OgreMaterial::setShadowCasterMaterial (const std::string& name) + { + mShadowCasterMaterial = name; + for (int i=0; i<mMaterial->getNumTechniques(); ++i) + { + mMaterial->getTechnique(i)->setShadowCasterMaterial(mShadowCasterMaterial); + } + } +} diff --git a/extern/shiny/Platforms/Ogre/OgreMaterial.hpp b/extern/shiny/Platforms/Ogre/OgreMaterial.hpp new file mode 100644 index 0000000000..bec23f0b6f --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreMaterial.hpp @@ -0,0 +1,38 @@ +#ifndef SH_OGREMATERIAL_H +#define SH_OGREMATERIAL_H + +#include <string> + +#include <OgreMaterial.h> + +#include "../../Main/Platform.hpp" + +namespace sh +{ + class OgreMaterial : public Material + { + public: + OgreMaterial (const std::string& name, const std::string& resourceGroup); + virtual ~OgreMaterial(); + + virtual boost::shared_ptr<Pass> createPass (const std::string& configuration, unsigned short lodIndex); + virtual bool createConfiguration (const std::string& name, unsigned short lodIndex); + + virtual void removeAll (); + + Ogre::MaterialPtr getOgreMaterial(); + + virtual void setLodLevels (const std::string& lodLevels); + + Ogre::Technique* getOgreTechniqueForConfiguration (const std::string& configurationName, unsigned short lodIndex = 0); + + virtual void setShadowCasterMaterial (const std::string& name); + + private: + Ogre::MaterialPtr mMaterial; + + std::string mShadowCasterMaterial; + }; +} + +#endif diff --git a/extern/shiny/Platforms/Ogre/OgreMaterialSerializer.cpp b/extern/shiny/Platforms/Ogre/OgreMaterialSerializer.cpp new file mode 100644 index 0000000000..9f57c7b441 --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreMaterialSerializer.cpp @@ -0,0 +1,67 @@ +#include "OgreMaterialSerializer.hpp" + +namespace sh +{ + void OgreMaterialSerializer::reset() + { + mScriptContext.section = Ogre::MSS_NONE; + mScriptContext.material.setNull(); + mScriptContext.technique = 0; + mScriptContext.pass = 0; + mScriptContext.textureUnit = 0; + mScriptContext.program.setNull(); + mScriptContext.lineNo = 0; + mScriptContext.filename.clear(); + mScriptContext.techLev = -1; + mScriptContext.passLev = -1; + mScriptContext.stateLev = -1; + } + + bool OgreMaterialSerializer::setPassProperty (const std::string& param, std::string value, Ogre::Pass* pass) + { + reset(); + + mScriptContext.section = Ogre::MSS_PASS; + mScriptContext.pass = pass; + + if (mPassAttribParsers.find (param) == mPassAttribParsers.end()) + return false; + else + { + mPassAttribParsers.find(param)->second(value, mScriptContext); + return true; + } + } + + bool OgreMaterialSerializer::setTextureUnitProperty (const std::string& param, std::string value, Ogre::TextureUnitState* t) + { + reset(); + + mScriptContext.section = Ogre::MSS_TEXTUREUNIT; + mScriptContext.textureUnit = t; + + if (mTextureUnitAttribParsers.find (param) == mTextureUnitAttribParsers.end()) + return false; + else + { + mTextureUnitAttribParsers.find(param)->second(value, mScriptContext); + return true; + } + } + + bool OgreMaterialSerializer::setMaterialProperty (const std::string& param, std::string value, Ogre::MaterialPtr m) + { + reset(); + + mScriptContext.section = Ogre::MSS_MATERIAL; + mScriptContext.material = m; + + if (mMaterialAttribParsers.find (param) == mMaterialAttribParsers.end()) + return false; + else + { + mMaterialAttribParsers.find(param)->second(value, mScriptContext); + return true; + } + } +} diff --git a/extern/shiny/Platforms/Ogre/OgreMaterialSerializer.hpp b/extern/shiny/Platforms/Ogre/OgreMaterialSerializer.hpp new file mode 100644 index 0000000000..acfc5a362f --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreMaterialSerializer.hpp @@ -0,0 +1,29 @@ +#ifndef SH_OGREMATERIALSERIALIZER_H +#define SH_OGREMATERIALSERIALIZER_H + +#include <OgreMaterialSerializer.h> + +namespace Ogre +{ + class Pass; +} + +namespace sh +{ + /** + * @brief This class allows me to let Ogre handle the pass & texture unit properties + */ + class OgreMaterialSerializer : public Ogre::MaterialSerializer + { + public: + bool setPassProperty (const std::string& param, std::string value, Ogre::Pass* pass); + bool setTextureUnitProperty (const std::string& param, std::string value, Ogre::TextureUnitState* t); + bool setMaterialProperty (const std::string& param, std::string value, Ogre::MaterialPtr m); + + private: + void reset(); + }; + +} + +#endif diff --git a/extern/shiny/Platforms/Ogre/OgrePass.cpp b/extern/shiny/Platforms/Ogre/OgrePass.cpp new file mode 100644 index 0000000000..8cfaae0788 --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgrePass.cpp @@ -0,0 +1,128 @@ +#include <stdexcept> + +#include "OgrePass.hpp" + +#include <OgrePass.h> +#include <OgreTechnique.h> + +#include "OgreTextureUnitState.hpp" +#include "OgreGpuProgram.hpp" +#include "OgreMaterial.hpp" +#include "OgreMaterialSerializer.hpp" +#include "OgrePlatform.hpp" + +namespace sh +{ + OgrePass::OgrePass (OgreMaterial* parent, const std::string& configuration, unsigned short lodIndex) + : Pass() + { + Ogre::Technique* t = parent->getOgreTechniqueForConfiguration(configuration, lodIndex); + mPass = t->createPass(); + } + + boost::shared_ptr<TextureUnitState> OgrePass::createTextureUnitState () + { + return boost::shared_ptr<TextureUnitState> (new OgreTextureUnitState (this)); + } + + void OgrePass::assignProgram (GpuProgramType type, const std::string& name) + { + if (type == GPT_Vertex) + mPass->setVertexProgram (name); + else if (type == GPT_Fragment) + mPass->setFragmentProgram (name); + else + throw std::runtime_error("unsupported GpuProgramType"); + } + + Ogre::Pass* OgrePass::getOgrePass () + { + return mPass; + } + + bool OgrePass::setPropertyOverride (const std::string &name, PropertyValuePtr& value, PropertySetGet* context) + { + if (((typeid(*value) == typeid(StringValue)) || typeid(*value) == typeid(LinkedValue)) + && retrieveValue<StringValue>(value, context).get() == "default") + return true; + + if (name == "vertex_program") + return true; // handled already + else if (name == "fragment_program") + return true; // handled already + else if (name == "ffp_vertex_colour_ambient") + { + bool enabled = retrieveValue<BooleanValue>(value, context).get(); + // fixed-function vertex colour tracking + mPass->setVertexColourTracking(enabled ? Ogre::TVC_AMBIENT : Ogre::TVC_NONE); + return true; + } + else + { + OgreMaterialSerializer& s = OgrePlatform::getSerializer(); + + return s.setPassProperty (name, retrieveValue<StringValue>(value, context).get(), mPass); + } + } + + void OgrePass::setGpuConstant (int type, const std::string& name, ValueType vt, PropertyValuePtr value, PropertySetGet* context) + { + Ogre::GpuProgramParametersSharedPtr params; + if (type == GPT_Vertex) + { + if (!mPass->hasVertexProgram ()) + return; + params = mPass->getVertexProgramParameters(); + } + else if (type == GPT_Fragment) + { + if (!mPass->hasFragmentProgram ()) + return; + params = mPass->getFragmentProgramParameters(); + } + + if (vt == VT_Float) + params->setNamedConstant (name, retrieveValue<FloatValue>(value, context).get()); + else if (vt == VT_Int) + params->setNamedConstant (name, retrieveValue<IntValue>(value, context).get()); + else if (vt == VT_Vector4) + { + Vector4 v = retrieveValue<Vector4>(value, context); + params->setNamedConstant (name, Ogre::Vector4(v.mX, v.mY, v.mZ, v.mW)); + } + else if (vt == VT_Vector3) + { + Vector3 v = retrieveValue<Vector3>(value, context); + params->setNamedConstant (name, Ogre::Vector4(v.mX, v.mY, v.mZ, 1.0)); + } + else if (vt == VT_Vector2) + { + Vector2 v = retrieveValue<Vector2>(value, context); + params->setNamedConstant (name, Ogre::Vector4(v.mX, v.mY, 1.0, 1.0)); + } + else + throw std::runtime_error ("unsupported constant type"); + } + + void OgrePass::addSharedParameter (int type, const std::string& name) + { + Ogre::GpuProgramParametersSharedPtr params; + if (type == GPT_Vertex) + params = mPass->getVertexProgramParameters(); + else if (type == GPT_Fragment) + params = mPass->getFragmentProgramParameters(); + + params->addSharedParameters (name); + } + + void OgrePass::setTextureUnitIndex (int programType, const std::string& name, int index) + { + Ogre::GpuProgramParametersSharedPtr params; + if (programType == GPT_Vertex) + params = mPass->getVertexProgramParameters(); + else if (programType == GPT_Fragment) + params = mPass->getFragmentProgramParameters(); + + params->setNamedConstant(name, index); + } +} diff --git a/extern/shiny/Platforms/Ogre/OgrePass.hpp b/extern/shiny/Platforms/Ogre/OgrePass.hpp new file mode 100644 index 0000000000..da67a1a2a5 --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgrePass.hpp @@ -0,0 +1,35 @@ +#ifndef SH_OGREPASS_H +#define SH_OGREPASS_H + +#include <OgrePass.h> + +#include "../../Main/Platform.hpp" + +namespace sh +{ + class OgreMaterial; + + class OgrePass : public Pass + { + public: + OgrePass (OgreMaterial* parent, const std::string& configuration, unsigned short lodIndex); + + virtual boost::shared_ptr<TextureUnitState> createTextureUnitState (); + virtual void assignProgram (GpuProgramType type, const std::string& name); + + Ogre::Pass* getOgrePass(); + + virtual void setGpuConstant (int type, const std::string& name, ValueType vt, PropertyValuePtr value, PropertySetGet* context); + + virtual void addSharedParameter (int type, const std::string& name); + virtual void setTextureUnitIndex (int programType, const std::string& name, int index); + + private: + Ogre::Pass* mPass; + + protected: + virtual bool setPropertyOverride (const std::string &name, PropertyValuePtr& value, PropertySetGet* context); + }; +} + +#endif diff --git a/extern/shiny/Platforms/Ogre/OgrePlatform.cpp b/extern/shiny/Platforms/Ogre/OgrePlatform.cpp new file mode 100644 index 0000000000..357949402f --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgrePlatform.cpp @@ -0,0 +1,174 @@ +#include <stdexcept> + +#include "OgrePlatform.hpp" + +#include <OgreDataStream.h> +#include <OgreGpuProgramManager.h> +#include <OgreRoot.h> + +#include "OgreMaterial.hpp" +#include "OgreGpuProgram.hpp" +#include "OgreMaterialSerializer.hpp" + +#include "../../Main/MaterialInstance.hpp" +#include "../../Main/Factory.hpp" + +namespace +{ + std::string convertLang (sh::Language lang) + { + if (lang == sh::Language_CG) + return "cg"; + else if (lang == sh::Language_HLSL) + return "hlsl"; + else if (lang == sh::Language_GLSL) + return "glsl"; + throw std::runtime_error ("invalid language, valid are: cg, hlsl, glsl"); + } +} + +namespace sh +{ + OgreMaterialSerializer* OgrePlatform::sSerializer = 0; + + OgrePlatform::OgrePlatform(const std::string& resourceGroupName, const std::string& basePath) + : Platform(basePath) + , mResourceGroup(resourceGroupName) + { + Ogre::MaterialManager::getSingleton().addListener(this); + + if (supportsShaderSerialization()) + Ogre::GpuProgramManager::getSingletonPtr()->setSaveMicrocodesToCache(true); + + sSerializer = new OgreMaterialSerializer(); + } + + OgreMaterialSerializer& OgrePlatform::getSerializer() + { + assert(sSerializer); + return *sSerializer; + } + + OgrePlatform::~OgrePlatform () + { + delete sSerializer; + } + + bool OgrePlatform::isProfileSupported (const std::string& profile) + { + return Ogre::GpuProgramManager::getSingleton().isSyntaxSupported(profile); + } + + bool OgrePlatform::supportsShaderSerialization () + { + // Not very reliable in OpenGL mode (requires extension), and somehow doesn't work on linux even if the extension is present + return Ogre::Root::getSingleton ().getRenderSystem ()->getName ().find("OpenGL") == std::string::npos; + } + + bool OgrePlatform::supportsMaterialQueuedListener () + { + return true; + } + + boost::shared_ptr<Material> OgrePlatform::createMaterial (const std::string& name) + { + OgreMaterial* material = new OgreMaterial(name, mResourceGroup); + return boost::shared_ptr<Material> (material); + } + + boost::shared_ptr<GpuProgram> OgrePlatform::createGpuProgram ( + GpuProgramType type, + const std::string& compileArguments, + const std::string& name, const std::string& profile, + const std::string& source, Language lang) + { + OgreGpuProgram* prog = new OgreGpuProgram (type, compileArguments, name, profile, source, convertLang(lang), mResourceGroup); + return boost::shared_ptr<GpuProgram> (static_cast<GpuProgram*>(prog)); + } + + Ogre::Technique* OgrePlatform::handleSchemeNotFound ( + unsigned short schemeIndex, const Ogre::String &schemeName, Ogre::Material *originalMaterial, + unsigned short lodIndex, const Ogre::Renderable *rend) + { + MaterialInstance* m = fireMaterialRequested(originalMaterial->getName(), schemeName, lodIndex); + if (m) + { + OgreMaterial* _m = static_cast<OgreMaterial*>(m->getMaterial()); + return _m->getOgreTechniqueForConfiguration (schemeName, lodIndex); + } + else + return 0; // material does not belong to us + } + + void OgrePlatform::serializeShaders (const std::string& file) + { + std::fstream output; + output.open(file.c_str(), std::ios::out | std::ios::binary); + Ogre::DataStreamPtr shaderCache (OGRE_NEW Ogre::FileStreamDataStream(file, &output, false)); + Ogre::GpuProgramManager::getSingleton().saveMicrocodeCache(shaderCache); + } + + void OgrePlatform::deserializeShaders (const std::string& file) + { + std::ifstream inp; + inp.open(file.c_str(), std::ios::in | std::ios::binary); + Ogre::DataStreamPtr shaderCache(OGRE_NEW Ogre::FileStreamDataStream(file, &inp, false)); + Ogre::GpuProgramManager::getSingleton().loadMicrocodeCache(shaderCache); + } + + void OgrePlatform::setSharedParameter (const std::string& name, PropertyValuePtr value) + { + Ogre::GpuSharedParametersPtr params; + if (mSharedParameters.find(name) == mSharedParameters.end()) + { + params = Ogre::GpuProgramManager::getSingleton().createSharedParameters(name); + Ogre::GpuConstantType type; + if (typeid(*value) == typeid(Vector4)) + type = Ogre::GCT_FLOAT4; + else if (typeid(*value) == typeid(Vector3)) + type = Ogre::GCT_FLOAT3; + else if (typeid(*value) == typeid(Vector2)) + type = Ogre::GCT_FLOAT2; + else if (typeid(*value) == typeid(FloatValue)) + type = Ogre::GCT_FLOAT1; + else if (typeid(*value) == typeid(IntValue)) + type = Ogre::GCT_INT1; + else + assert(0); + params->addConstantDefinition(name, type); + mSharedParameters[name] = params; + } + else + params = mSharedParameters.find(name)->second; + + Ogre::Vector4 v (1.0, 1.0, 1.0, 1.0); + if (typeid(*value) == typeid(Vector4)) + { + Vector4 vec = retrieveValue<Vector4>(value, NULL); + v.x = vec.mX; + v.y = vec.mY; + v.z = vec.mZ; + v.w = vec.mW; + } + else if (typeid(*value) == typeid(Vector3)) + { + Vector3 vec = retrieveValue<Vector3>(value, NULL); + v.x = vec.mX; + v.y = vec.mY; + v.z = vec.mZ; + } + else if (typeid(*value) == typeid(Vector2)) + { + Vector2 vec = retrieveValue<Vector2>(value, NULL); + v.x = vec.mX; + v.y = vec.mY; + } + else if (typeid(*value) == typeid(FloatValue)) + v.x = retrieveValue<FloatValue>(value, NULL).get(); + else if (typeid(*value) == typeid(IntValue)) + v.x = static_cast<float>(retrieveValue<IntValue>(value, NULL).get()); + else + throw std::runtime_error ("unsupported property type for shared parameter \"" + name + "\""); + params->setNamedConstant(name, v); + } +} diff --git a/extern/shiny/Platforms/Ogre/OgrePlatform.hpp b/extern/shiny/Platforms/Ogre/OgrePlatform.hpp new file mode 100644 index 0000000000..d115c46bb4 --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgrePlatform.hpp @@ -0,0 +1,72 @@ +#ifndef SH_OGREPLATFORM_H +#define SH_OGREPLATFORM_H + +/** + * @addtogroup Platforms + * @{ + */ + +/** + * @addtogroup Ogre + * A set of classes to interact with Ogre's material system + * @{ + */ + +#include "../../Main/Platform.hpp" + +#include <OgreMaterialManager.h> +#include <OgreGpuProgramParams.h> + +namespace sh +{ + class OgreMaterialSerializer; + + class OgrePlatform : public Platform, public Ogre::MaterialManager::Listener + { + public: + OgrePlatform (const std::string& resourceGroupName, const std::string& basePath); + virtual ~OgrePlatform (); + + virtual Ogre::Technique* handleSchemeNotFound ( + unsigned short schemeIndex, const Ogre::String &schemeName, Ogre::Material *originalMaterial, + unsigned short lodIndex, const Ogre::Renderable *rend); + + static OgreMaterialSerializer& getSerializer(); + + private: + virtual bool isProfileSupported (const std::string& profile); + + virtual void serializeShaders (const std::string& file); + virtual void deserializeShaders (const std::string& file); + + virtual boost::shared_ptr<Material> createMaterial (const std::string& name); + + virtual boost::shared_ptr<GpuProgram> createGpuProgram ( + GpuProgramType type, + const std::string& compileArguments, + const std::string& name, const std::string& profile, + const std::string& source, Language lang); + + virtual void setSharedParameter (const std::string& name, PropertyValuePtr value); + + friend class ShaderInstance; + friend class Factory; + + protected: + virtual bool supportsShaderSerialization (); + virtual bool supportsMaterialQueuedListener (); + + std::string mResourceGroup; + + static OgreMaterialSerializer* sSerializer; + + std::map <std::string, Ogre::GpuSharedParametersPtr> mSharedParameters; + }; +} + +/** + * @} + * @} + */ + +#endif diff --git a/extern/shiny/Platforms/Ogre/OgreTextureUnitState.cpp b/extern/shiny/Platforms/Ogre/OgreTextureUnitState.cpp new file mode 100644 index 0000000000..0938cf667d --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreTextureUnitState.cpp @@ -0,0 +1,40 @@ +#include "OgreTextureUnitState.hpp" + +#include "OgrePass.hpp" +#include "OgrePlatform.hpp" +#include "OgreMaterialSerializer.hpp" + +namespace sh +{ + OgreTextureUnitState::OgreTextureUnitState (OgrePass* parent) + : TextureUnitState() + { + mTextureUnitState = parent->getOgrePass()->createTextureUnitState(""); + } + + bool OgreTextureUnitState::setPropertyOverride (const std::string &name, PropertyValuePtr& value, PropertySetGet* context) + { + OgreMaterialSerializer& s = OgrePlatform::getSerializer(); + + if (name == "texture_alias") + { + // texture alias in this library refers to something else than in ogre + // delegate up + return TextureUnitState::setPropertyOverride (name, value, context); + } + else if (name == "direct_texture") + { + setTextureName (retrieveValue<StringValue>(value, context).get()); + return true; + } + else if (name == "create_in_ffp") + return true; // handled elsewhere + + return s.setTextureUnitProperty (name, retrieveValue<StringValue>(value, context).get(), mTextureUnitState); + } + + void OgreTextureUnitState::setTextureName (const std::string& textureName) + { + mTextureUnitState->setTextureName(textureName); + } +} diff --git a/extern/shiny/Platforms/Ogre/OgreTextureUnitState.hpp b/extern/shiny/Platforms/Ogre/OgreTextureUnitState.hpp new file mode 100644 index 0000000000..d36f4b945a --- /dev/null +++ b/extern/shiny/Platforms/Ogre/OgreTextureUnitState.hpp @@ -0,0 +1,27 @@ +#ifndef SH_OGRETEXTUREUNITSTATE_H +#define SH_OGRETEXTUREUNITSTATE_H + +#include <OgreTextureUnitState.h> + +#include "../../Main/Platform.hpp" + +namespace sh +{ + class OgrePass; + + class OgreTextureUnitState : public TextureUnitState + { + public: + OgreTextureUnitState (OgrePass* parent); + + virtual void setTextureName (const std::string& textureName); + + private: + Ogre::TextureUnitState* mTextureUnitState; + + protected: + virtual bool setPropertyOverride (const std::string &name, PropertyValuePtr& value, PropertySetGet* context); + }; +} + +#endif diff --git a/extern/shiny/Preprocessor/aq.cpp b/extern/shiny/Preprocessor/aq.cpp new file mode 100644 index 0000000000..b81d5b3324 --- /dev/null +++ b/extern/shiny/Preprocessor/aq.cpp @@ -0,0 +1,236 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + http://www.boost.org/ + + Copyright (c) 2001 Daniel C. Nuffer. + Copyright (c) 2001-2011 Hartmut Kaiser. + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> + +#include <cstdlib> +#include <cstring> + +#include <boost/wave/wave_config.hpp> // configuration data +#include <boost/wave/cpplexer/re2clex/aq.hpp> + +#include <boost/assert.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { +namespace wave { +namespace cpplexer { +namespace re2clex { + +int aq_grow(aq_queue q) +{ + using namespace std; // some systems have memcpy/realloc in std + std::size_t new_size = q->max_size << 1; + aq_stdelement* new_queue = (aq_stdelement*)realloc(q->queue, + new_size * sizeof(aq_stdelement)); + + BOOST_ASSERT(NULL != q); + BOOST_ASSERT(q->max_size < 100000); + BOOST_ASSERT(q->size <= q->max_size); + +#define ASSERT_SIZE BOOST_ASSERT( \ + ((q->tail + q->max_size + 1) - q->head) % q->max_size == \ + q->size % q->max_size) + + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + if (!new_queue) + { + BOOST_ASSERT(0); + return 0; + } + + q->queue = new_queue; + if (q->tail <= q->head) /* tail has wrapped around */ + { + /* move the tail from the beginning to the end */ + memcpy(q->queue + q->max_size, q->queue, + (q->tail + 1) * sizeof(aq_stdelement)); + q->tail += q->max_size; + } + q->max_size = new_size; + + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + return 1; +} + +int aq_enqueue(aq_queue q, aq_stdelement e) +{ + BOOST_ASSERT(NULL != q); + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + + if (AQ_FULL(q)) + if (!aq_grow(q)) + return 0; + + ++q->tail; + if (q->tail == q->max_size) + q->tail = 0; + + q->queue[q->tail] = e; + ++q->size; + + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + return 1; +} + +int aq_enqueue_front(aq_queue q, aq_stdelement e) +{ + BOOST_ASSERT(NULL != q); + + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + + if (AQ_FULL(q)) + if (!aq_grow(q)) + return 0; + + if (q->head == 0) + q->head = q->max_size - 1; + else + --q->head; + + q->queue[q->head] = e; + ++q->size; + + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + return 1; +} + +int aq_serve(aq_queue q, aq_stdelement *e) +{ + + BOOST_ASSERT(NULL != q); + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + + if (AQ_EMPTY(q)) + return 0; + + *e = q->queue[q->head]; + return aq_pop(q); +} + +int aq_pop(aq_queue q) +{ + + BOOST_ASSERT(NULL != q); + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + + if (AQ_EMPTY(q)) + return 0; + + ++q->head; + if (q->head == q->max_size) + q->head = 0; + --q->size; + + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + return 1; +} + +aq_queue aq_create(void) +{ + aq_queue q; + + using namespace std; // some systems have malloc in std + q = (aq_queue)malloc(sizeof(aq_queuetype)); + if (!q) + { + return 0; + } + + q->max_size = 8; /* initial size */ + q->queue = (aq_stdelement*)malloc( + sizeof(aq_stdelement) * q->max_size); + if (!q->queue) + { + free(q); + return 0; + } + + q->head = 0; + q->tail = q->max_size - 1; + q->size = 0; + + + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + return q; +} + +void aq_terminate(aq_queue q) +{ + using namespace std; // some systems have free in std + + BOOST_ASSERT(NULL != q); + BOOST_ASSERT(q->size <= q->max_size); + ASSERT_SIZE; + BOOST_ASSERT(q->head <= q->max_size); + BOOST_ASSERT(q->tail <= q->max_size); + + free(q->queue); + free(q); +} + +/////////////////////////////////////////////////////////////////////////////// +} // namespace re2clex +} // namespace cpplexer +} // namespace wave +} // namespace boost + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + diff --git a/extern/shiny/Preprocessor/cpp_re.cpp b/extern/shiny/Preprocessor/cpp_re.cpp new file mode 100644 index 0000000000..69d77c3726 --- /dev/null +++ b/extern/shiny/Preprocessor/cpp_re.cpp @@ -0,0 +1,442 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + + Copyright (c) 2001 Daniel C. Nuffer + Copyright (c) 2001-2011 Hartmut Kaiser. + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + TODO: + It also may be necessary to add $ to identifiers, for asm. + handle errors better. + have some easier way to parse strings instead of files (done) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> + +#include <ctime> +#include <cstdlib> +#include <cstdio> +#include <cstring> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> + +#include <boost/wave/wave_config.hpp> // configuration data + +#if defined(BOOST_HAS_UNISTD_H) +#include <unistd.h> +#else +#include <io.h> +#endif + +#include <boost/assert.hpp> +#include <boost/detail/workaround.hpp> + +#include <boost/wave/token_ids.hpp> +#include <boost/wave/cpplexer/re2clex/aq.hpp> +#include <boost/wave/cpplexer/re2clex/scanner.hpp> +#include <boost/wave/cpplexer/re2clex/cpp_re.hpp> +#include <boost/wave/cpplexer/cpplexer_exceptions.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +#if defined(BOOST_MSVC) +#pragma warning (disable: 4101) // 'foo' : unreferenced local variable +#pragma warning (disable: 4102) // 'foo' : unreferenced label +#endif + +/////////////////////////////////////////////////////////////////////////////// +#define BOOST_WAVE_BSIZE 196608 + +#define YYCTYPE uchar +#define YYCURSOR cursor +#define YYLIMIT limit +#define YYMARKER marker +#define YYFILL(n) \ + { \ + cursor = uchar_wrapper(fill(s, cursor), cursor.column); \ + limit = uchar_wrapper (s->lim); \ + } \ + /**/ + +#include <iostream> + +/////////////////////////////////////////////////////////////////////////////// +#define BOOST_WAVE_UPDATE_CURSOR() \ + { \ + s->line += count_backslash_newlines(s, cursor); \ + s->curr_column = cursor.column; \ + s->cur = cursor; \ + s->lim = limit; \ + s->ptr = marker; \ + } \ + /**/ + +/////////////////////////////////////////////////////////////////////////////// +#define BOOST_WAVE_RET(i) \ + { \ + BOOST_WAVE_UPDATE_CURSOR() \ + if (s->cur > s->lim) \ + return T_EOF; /* may happen for empty files */ \ + return (i); \ + } \ + /**/ + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { +namespace wave { +namespace cpplexer { +namespace re2clex { + +#define RE2C_ASSERT BOOST_ASSERT + +int get_one_char(Scanner *s) +{ + if (0 != s->act) { + RE2C_ASSERT(s->first != 0 && s->last != 0); + RE2C_ASSERT(s->first <= s->act && s->act <= s->last); + if (s->act < s->last) + return *(s->act)++; + } + return -1; +} + +std::ptrdiff_t rewind_stream (Scanner *s, int cnt) +{ + if (0 != s->act) { + RE2C_ASSERT(s->first != 0 && s->last != 0); + s->act += cnt; + RE2C_ASSERT(s->first <= s->act && s->act <= s->last); + return s->act - s->first; + } + return 0; +} + +std::size_t get_first_eol_offset(Scanner* s) +{ + if (!AQ_EMPTY(s->eol_offsets)) + { + return s->eol_offsets->queue[s->eol_offsets->head]; + } + else + { + return (unsigned int)-1; + } +} + +void adjust_eol_offsets(Scanner* s, std::size_t adjustment) +{ + aq_queue q; + std::size_t i; + + if (!s->eol_offsets) + s->eol_offsets = aq_create(); + + q = s->eol_offsets; + + if (AQ_EMPTY(q)) + return; + + i = q->head; + while (i != q->tail) + { + if (adjustment > q->queue[i]) + q->queue[i] = 0; + else + q->queue[i] -= adjustment; + ++i; + if (i == q->max_size) + i = 0; + } + if (adjustment > q->queue[i]) + q->queue[i] = 0; + else + q->queue[i] -= adjustment; +} + +int count_backslash_newlines(Scanner *s, uchar *cursor) +{ + std::size_t diff, offset; + int skipped = 0; + + /* figure out how many backslash-newlines skipped over unknowingly. */ + diff = cursor - s->bot; + offset = get_first_eol_offset(s); + while (offset <= diff && offset != (unsigned int)-1) + { + skipped++; + aq_pop(s->eol_offsets); + offset = get_first_eol_offset(s); + } + return skipped; +} + +bool is_backslash(uchar *p, uchar *end, int &len) +{ + if (*p == '\\') { + len = 1; + return true; + } + else if (*p == '?' && *(p+1) == '?' && (p+2 < end && *(p+2) == '/')) { + len = 3; + return true; + } + return false; +} + +uchar *fill(Scanner *s, uchar *cursor) +{ + using namespace std; // some systems have memcpy etc. in namespace std + if(!s->eof) + { + uchar* p; + std::ptrdiff_t cnt = s->tok - s->bot; + if(cnt) + { + if (NULL == s->lim) + s->lim = s->top; + memmove(s->bot, s->tok, s->lim - s->tok); + s->tok = s->cur = s->bot; + s->ptr -= cnt; + cursor -= cnt; + s->lim -= cnt; + adjust_eol_offsets(s, cnt); + } + + if((s->top - s->lim) < BOOST_WAVE_BSIZE) + { + uchar *buf = (uchar*) malloc(((s->lim - s->bot) + BOOST_WAVE_BSIZE)*sizeof(uchar)); + if (buf == 0) + { + using namespace std; // some systems have printf in std + if (0 != s->error_proc) { + (*s->error_proc)(s, lexing_exception::unexpected_error, + "Out of memory!"); + } + else + printf("Out of memory!\n"); + + /* get the scanner to stop */ + *cursor = 0; + return cursor; + } + + memmove(buf, s->tok, s->lim - s->tok); + s->tok = s->cur = buf; + s->ptr = &buf[s->ptr - s->bot]; + cursor = &buf[cursor - s->bot]; + s->lim = &buf[s->lim - s->bot]; + s->top = &s->lim[BOOST_WAVE_BSIZE]; + free(s->bot); + s->bot = buf; + } + + if (s->act != 0) { + cnt = s->last - s->act; + if (cnt > BOOST_WAVE_BSIZE) + cnt = BOOST_WAVE_BSIZE; + memmove(s->lim, s->act, cnt); + s->act += cnt; + if (cnt != BOOST_WAVE_BSIZE) + { + s->eof = &s->lim[cnt]; *(s->eof)++ = '\0'; + } + } + + /* backslash-newline erasing time */ + + /* first scan for backslash-newline and erase them */ + for (p = s->lim; p < s->lim + cnt - 2; ++p) + { + int len = 0; + if (is_backslash(p, s->lim + cnt, len)) + { + if (*(p+len) == '\n') + { + int offset = len + 1; + memmove(p, p + offset, s->lim + cnt - p - offset); + cnt -= offset; + --p; + aq_enqueue(s->eol_offsets, p - s->bot + 1); + } + else if (*(p+len) == '\r') + { + if (*(p+len+1) == '\n') + { + int offset = len + 2; + memmove(p, p + offset, s->lim + cnt - p - offset); + cnt -= offset; + --p; + } + else + { + int offset = len + 1; + memmove(p, p + offset, s->lim + cnt - p - offset); + cnt -= offset; + --p; + } + aq_enqueue(s->eol_offsets, p - s->bot + 1); + } + } + } + + /* FIXME: the following code should be fixed to recognize correctly the + trigraph backslash token */ + + /* check to see if what we just read ends in a backslash */ + if (cnt >= 2) + { + uchar last = s->lim[cnt-1]; + uchar last2 = s->lim[cnt-2]; + /* check \ EOB */ + if (last == '\\') + { + int next = get_one_char(s); + /* check for \ \n or \ \r or \ \r \n straddling the border */ + if (next == '\n') + { + --cnt; /* chop the final \, we've already read the \n. */ + aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot)); + } + else if (next == '\r') + { + int next2 = get_one_char(s); + if (next2 == '\n') + { + --cnt; /* skip the backslash */ + } + else + { + /* rewind one, and skip one char */ + rewind_stream(s, -1); + --cnt; + } + aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot)); + } + else if (next != -1) /* -1 means end of file */ + { + /* next was something else, so rewind the stream */ + rewind_stream(s, -1); + } + } + /* check \ \r EOB */ + else if (last == '\r' && last2 == '\\') + { + int next = get_one_char(s); + if (next == '\n') + { + cnt -= 2; /* skip the \ \r */ + } + else + { + /* rewind one, and skip two chars */ + rewind_stream(s, -1); + cnt -= 2; + } + aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot)); + } + /* check \ \n EOB */ + else if (last == '\n' && last2 == '\\') + { + cnt -= 2; + aq_enqueue(s->eol_offsets, cnt + (s->lim - s->bot)); + } + } + + s->lim += cnt; + if (s->eof) /* eof needs adjusting if we erased backslash-newlines */ + { + s->eof = s->lim; + *(s->eof)++ = '\0'; + } + } + return cursor; +} + +/////////////////////////////////////////////////////////////////////////////// +// Special wrapper class holding the current cursor position +struct uchar_wrapper +{ + uchar_wrapper (uchar *base_cursor, unsigned int column = 1) + : base_cursor(base_cursor), column(column) + {} + + uchar_wrapper& operator++() + { + ++base_cursor; + ++column; + return *this; + } + + uchar_wrapper& operator--() + { + --base_cursor; + --column; + return *this; + } + + uchar operator* () const + { + return *base_cursor; + } + + operator uchar *() const + { + return base_cursor; + } + + friend std::ptrdiff_t + operator- (uchar_wrapper const& lhs, uchar_wrapper const& rhs) + { + return lhs.base_cursor - rhs.base_cursor; + } + + uchar *base_cursor; + unsigned int column; +}; + +/////////////////////////////////////////////////////////////////////////////// +boost::wave::token_id scan(Scanner *s) +{ + BOOST_ASSERT(0 != s->error_proc); // error handler must be given + + uchar_wrapper cursor (s->tok = s->cur, s->column = s->curr_column); + uchar_wrapper marker (s->ptr); + uchar_wrapper limit (s->lim); + +// include the correct Re2C token definition rules +#if BOOST_WAVE_USE_STRICT_LEXER != 0 +#include "strict_cpp_re.inc" +#else +#include "cpp_re.inc" +#endif + +} /* end of scan */ + +/////////////////////////////////////////////////////////////////////////////// +} // namespace re2clex +} // namespace cpplexer +} // namespace wave +} // namespace boost + +#undef BOOST_WAVE_RET +#undef BOOST_WAVE_BSIZE +#undef YYCTYPE +#undef YYCURSOR +#undef YYLIMIT +#undef YYMARKER +#undef YYFILL + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + diff --git a/extern/shiny/Preprocessor/cpp_re.inc b/extern/shiny/Preprocessor/cpp_re.inc new file mode 100644 index 0000000000..afb7fc189e --- /dev/null +++ b/extern/shiny/Preprocessor/cpp_re.inc @@ -0,0 +1,9044 @@ +/* Generated by re2c 0.13.5 on Sun Jan 09 15:38:23 2011 */ +#line 1 "cpp.re" +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + + Copyright (c) 2001 Daniel C. Nuffer + Copyright (c) 2001-2011 Hartmut Kaiser. + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + + This is a lexer conforming to the Standard with a few exceptions. + So it does allow the '$' to be part of identifiers. If you need strict + Standards conforming behaviour, please include the lexer definition + provided in the file strict_cpp.re. + + TODO: + handle errors better. +=============================================================================*/ + +#line 40 "cpp.re" + + + +#line 25 "cpp_re.inc" +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = { + /* table 1 .. 8: 0 */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 60, 32, 60, 60, 64, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 60, 60, 52, 60, 60, 60, 60, 56, + 60, 60, 156, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 44, 57, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 58, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, + /* table 9 .. 12: 256 */ + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 80, 0, 80, 80, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 80, 64, 0, 64, 96, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 64, 64, 64, 64, 64, 0, + 64, 224, 224, 224, 224, 224, 224, 96, + 96, 96, 96, 96, 96, 96, 96, 96, + 96, 96, 96, 96, 96, 96, 96, 96, + 96, 96, 96, 64, 0, 64, 64, 96, + 64, 224, 224, 224, 224, 224, 224, 96, + 96, 96, 96, 96, 96, 96, 96, 96, + 96, 96, 96, 96, 96, 96, 96, 96, + 96, 96, 96, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + }; + + if ((YYLIMIT - YYCURSOR) < 17) YYFILL(17); + yych = *YYCURSOR; + switch (yych) { + case 0x00: goto yy90; + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x08: + case 0x0E: + case 0x0F: + case 0x10: + case 0x11: + case 0x12: + case 0x13: + case 0x14: + case 0x15: + case 0x16: + case 0x17: + case 0x18: + case 0x19: + case 0x1A: + case 0x1B: + case 0x1C: + case 0x1D: + case 0x1E: + case 0x1F: goto yy93; + case '\t': + case '\v': + case '\f': goto yy84; + case '\n': goto yy87; + case '\r': goto yy89; + case ' ': goto yy86; + case '!': goto yy68; + case '"': goto yy79; + case '#': goto yy45; + case '$': + case 'A': + case 'B': + case 'C': + case 'D': + case 'E': + case 'F': + case 'G': + case 'H': + case 'I': + case 'J': + case 'K': + case 'M': + case 'N': + case 'O': + case 'P': + case 'Q': + case 'S': + case 'T': + case 'V': + case 'W': + case 'X': + case 'Y': + case 'Z': + case 'h': + case 'j': + case 'k': + case 'q': + case 'y': + case 'z': goto yy82; + case '%': goto yy37; + case '&': goto yy62; + case '\'': goto yy77; + case '(': goto yy47; + case ')': goto yy49; + case '*': goto yy57; + case '+': goto yy53; + case ',': goto yy74; + case '-': goto yy55; + case '.': goto yy4; + case '/': goto yy2; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': goto yy6; + case ':': goto yy43; + case ';': goto yy51; + case '<': goto yy33; + case '=': goto yy70; + case '>': goto yy72; + case '?': goto yy31; + case 'L': goto yy76; + case 'R': goto yy80; + case 'U': goto yy81; + case '[': goto yy39; + case '\\': goto yy83; + case ']': goto yy41; + case '^': goto yy59; + case '_': goto yy28; + case 'a': goto yy8; + case 'b': goto yy10; + case 'c': goto yy11; + case 'd': goto yy12; + case 'e': goto yy13; + case 'f': goto yy14; + case 'g': goto yy15; + case 'i': goto yy16; + case 'l': goto yy17; + case 'm': goto yy18; + case 'n': goto yy19; + case 'o': goto yy20; + case 'p': goto yy21; + case 'r': goto yy22; + case 's': goto yy23; + case 't': goto yy24; + case 'u': goto yy25; + case 'v': goto yy26; + case 'w': goto yy27; + case 'x': goto yy61; + case '{': goto yy29; + case '|': goto yy64; + case '}': goto yy35; + case '~': goto yy66; + default: goto yy92; + } +yy2: + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '.') { + if (yych == '*') goto yy998; + } else { + if (yych <= '/') goto yy996; + if (yych == '=') goto yy994; + } +#line 188 "cpp.re" + { BOOST_WAVE_RET(T_DIVIDE); } +#line 238 "cpp_re.inc" +yy4: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '-') { + if (yych == '*') goto yy988; + } else { + if (yych <= '.') goto yy990; + if (yych <= '/') goto yy5; + if (yych <= '9') goto yy991; + } +yy5: +#line 174 "cpp.re" + { BOOST_WAVE_RET(T_DOT); } +#line 252 "cpp_re.inc" +yy6: + ++YYCURSOR; +yy7: +#line 45 "cpp.re" + { goto pp_number; } +#line 258 "cpp_re.inc" +yy8: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'l': goto yy964; + case 'n': goto yy965; + case 's': goto yy966; + case 'u': goto yy967; + default: goto yy109; + } +yy9: +#line 290 "cpp.re" + { BOOST_WAVE_RET(T_IDENTIFIER); } +#line 272 "cpp_re.inc" +yy10: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'n') { + if (yych == 'i') goto yy946; + goto yy109; + } else { + if (yych <= 'o') goto yy947; + if (yych == 'r') goto yy948; + goto yy109; + } +yy11: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'a': goto yy893; + case 'h': goto yy894; + case 'l': goto yy895; + case 'o': goto yy896; + default: goto yy109; + } +yy12: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'n') { + if (yych == 'e') goto yy855; + goto yy109; + } else { + if (yych <= 'o') goto yy856; + if (yych == 'y') goto yy858; + goto yy109; + } +yy13: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'm') { + if (yych == 'l') goto yy830; + goto yy109; + } else { + if (yych <= 'n') goto yy831; + if (yych == 'x') goto yy832; + goto yy109; + } +yy14: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'a': goto yy811; + case 'l': goto yy812; + case 'o': goto yy813; + case 'r': goto yy814; + default: goto yy109; + } +yy15: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy807; + goto yy109; +yy16: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'l') { + if (yych == 'f') goto yy791; + goto yy109; + } else { + if (yych <= 'm') goto yy793; + if (yych <= 'n') goto yy794; + goto yy109; + } +yy17: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy787; + goto yy109; +yy18: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'u') goto yy780; + goto yy109; +yy19: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'e') { + if (yych == 'a') goto yy747; + if (yych <= 'd') goto yy109; + goto yy748; + } else { + if (yych <= 'o') { + if (yych <= 'n') goto yy109; + goto yy749; + } else { + if (yych == 'u') goto yy750; + goto yy109; + } + } +yy20: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'p') goto yy733; + if (yych == 'r') goto yy734; + goto yy109; +yy21: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'r') goto yy712; + if (yych == 'u') goto yy713; + goto yy109; +yy22: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy684; + goto yy109; +yy23: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 's') { + if (yych <= 'g') goto yy109; + if (yych <= 'h') goto yy638; + if (yych <= 'i') goto yy639; + goto yy109; + } else { + if (yych <= 't') goto yy640; + if (yych == 'w') goto yy641; + goto yy109; + } +yy24: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'h') { + if (yych == 'e') goto yy591; + if (yych <= 'g') goto yy109; + goto yy592; + } else { + if (yych <= 'r') { + if (yych <= 'q') goto yy109; + goto yy593; + } else { + if (yych == 'y') goto yy594; + goto yy109; + } + } +yy25: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '8') { + if (yych <= '&') { + if (yych == '"') goto yy129; + goto yy109; + } else { + if (yych <= '\'') goto yy131; + if (yych <= '7') goto yy109; + goto yy573; + } + } else { + if (yych <= 'm') { + if (yych == 'R') goto yy128; + goto yy109; + } else { + if (yych <= 'n') goto yy574; + if (yych == 's') goto yy575; + goto yy109; + } + } +yy26: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy555; + if (yych == 'o') goto yy556; + goto yy109; +yy27: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'c') goto yy543; + if (yych == 'h') goto yy544; + goto yy109; +yy28: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case '_': goto yy454; + case 'a': goto yy455; + case 'b': goto yy456; + case 'c': goto yy457; + case 'd': goto yy458; + case 'f': goto yy459; + case 'i': goto yy460; + case 's': goto yy461; + default: goto yy109; + } +yy29: + ++YYCURSOR; +#line 138 "cpp.re" + { BOOST_WAVE_RET(T_LEFTBRACE); } +#line 466 "cpp_re.inc" +yy31: + yyaccept = 2; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '?') goto yy419; +yy32: +#line 163 "cpp.re" + { BOOST_WAVE_RET(T_QUESTION_MARK); } +#line 474 "cpp_re.inc" +yy33: + ++YYCURSOR; + if ((yych = *YYCURSOR) <= ':') { + if (yych == '%') goto yy415; + if (yych >= ':') goto yy413; + } else { + if (yych <= ';') goto yy34; + if (yych <= '<') goto yy411; + if (yych <= '=') goto yy409; + } +yy34: +#line 204 "cpp.re" + { BOOST_WAVE_RET(T_LESS); } +#line 488 "cpp_re.inc" +yy35: + ++YYCURSOR; +#line 141 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTBRACE); } +#line 493 "cpp_re.inc" +yy37: + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '<') { + if (yych == ':') goto yy400; + } else { + if (yych <= '=') goto yy402; + if (yych <= '>') goto yy404; + } +#line 189 "cpp.re" + { BOOST_WAVE_RET(T_PERCENT); } +#line 504 "cpp_re.inc" +yy39: + ++YYCURSOR; +#line 144 "cpp.re" + { BOOST_WAVE_RET(T_LEFTBRACKET); } +#line 509 "cpp_re.inc" +yy41: + ++YYCURSOR; +#line 147 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTBRACKET); } +#line 514 "cpp_re.inc" +yy43: + ++YYCURSOR; + if ((yych = *YYCURSOR) == ':') goto yy396; + if (yych == '>') goto yy398; +#line 161 "cpp.re" + { BOOST_WAVE_RET(T_COLON); } +#line 521 "cpp_re.inc" +yy45: + yyaccept = 3; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'c') { + if (yych <= ' ') { + if (yych <= '\n') { + if (yych == '\t') goto yy273; + } else { + if (yych <= '\f') goto yy273; + if (yych >= ' ') goto yy273; + } + } else { + if (yych <= '.') { + if (yych == '#') goto yy284; + } else { + if (yych <= '/') goto yy273; + if (yych == '?') goto yy283; + } + } + } else { + if (yych <= 'p') { + if (yych <= 'i') { + if (yych <= 'e') goto yy273; + if (yych >= 'i') goto yy273; + } else { + if (yych == 'l') goto yy273; + if (yych >= 'p') goto yy273; + } + } else { + if (yych <= 't') { + if (yych == 'r') goto yy273; + } else { + if (yych == 'v') goto yy46; + if (yych <= 'w') goto yy273; + } + } + } +yy46: +#line 150 "cpp.re" + { BOOST_WAVE_RET(T_POUND); } +#line 562 "cpp_re.inc" +yy47: + ++YYCURSOR; +#line 158 "cpp.re" + { BOOST_WAVE_RET(T_LEFTPAREN); } +#line 567 "cpp_re.inc" +yy49: + ++YYCURSOR; +#line 159 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTPAREN); } +#line 572 "cpp_re.inc" +yy51: + ++YYCURSOR; +#line 160 "cpp.re" + { BOOST_WAVE_RET(T_SEMICOLON); } +#line 577 "cpp_re.inc" +yy53: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '+') goto yy268; + if (yych == '=') goto yy270; +#line 185 "cpp.re" + { BOOST_WAVE_RET(T_PLUS); } +#line 584 "cpp_re.inc" +yy55: + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '<') { + if (yych == '-') goto yy262; + } else { + if (yych <= '=') goto yy264; + if (yych <= '>') goto yy260; + } +#line 186 "cpp.re" + { BOOST_WAVE_RET(T_MINUS); } +#line 595 "cpp_re.inc" +yy57: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy258; +#line 187 "cpp.re" + { BOOST_WAVE_RET(T_STAR); } +#line 601 "cpp_re.inc" +yy59: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy256; +#line 190 "cpp.re" + { BOOST_WAVE_RET(T_XOR); } +#line 607 "cpp_re.inc" +yy61: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy249; + goto yy109; +yy62: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '&') goto yy245; + if (yych == '=') goto yy247; +#line 193 "cpp.re" + { BOOST_WAVE_RET(T_AND); } +#line 619 "cpp_re.inc" +yy64: + yyaccept = 4; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '>') { + if (yych == '=') goto yy240; + } else { + if (yych <= '?') goto yy237; + if (yych == '|') goto yy238; + } +yy65: +#line 195 "cpp.re" + { BOOST_WAVE_RET(T_OR); } +#line 632 "cpp_re.inc" +yy66: + ++YYCURSOR; +#line 198 "cpp.re" + { BOOST_WAVE_RET(T_COMPL); } +#line 637 "cpp_re.inc" +yy68: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy235; +#line 201 "cpp.re" + { BOOST_WAVE_RET(T_NOT); } +#line 643 "cpp_re.inc" +yy70: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy233; +#line 203 "cpp.re" + { BOOST_WAVE_RET(T_ASSIGN); } +#line 649 "cpp_re.inc" +yy72: + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '<') goto yy73; + if (yych <= '=') goto yy227; + if (yych <= '>') goto yy229; +yy73: +#line 205 "cpp.re" + { BOOST_WAVE_RET(T_GREATER); } +#line 658 "cpp_re.inc" +yy74: + ++YYCURSOR; +#line 237 "cpp.re" + { BOOST_WAVE_RET(T_COMMA); } +#line 663 "cpp_re.inc" +yy76: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '?') { + if (yych <= '&') { + if (yych <= '"') { + if (yych <= '!') goto yy9; + goto yy137; + } else { + if (yych == '$') goto yy108; + goto yy9; + } + } else { + if (yych <= '/') { + if (yych <= '\'') goto yy226; + goto yy9; + } else { + if (yych <= '9') goto yy108; + if (yych <= '>') goto yy9; + goto yy111; + } + } + } else { + if (yych <= '[') { + if (yych <= 'Q') { + if (yych <= '@') goto yy9; + goto yy108; + } else { + if (yych <= 'R') goto yy225; + if (yych <= 'Z') goto yy108; + goto yy9; + } + } else { + if (yych <= '_') { + if (yych <= '\\') goto yy110; + if (yych <= '^') goto yy9; + goto yy108; + } else { + if (yych <= '`') goto yy9; + if (yych <= 'z') goto yy108; + goto yy9; + } + } + } +yy77: + yyaccept = 5; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\f') { + if (yych == '\t') goto yy182; + if (yych >= '\v') goto yy182; + } else { + if (yych <= 0x1F) goto yy78; + if (yych != '\'') goto yy182; + } +yy78: +#line 339 "cpp.re" + { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); } +#line 721 "cpp_re.inc" +yy79: + yyaccept = 5; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\n') { + if (yych == '\t') goto yy138; + goto yy78; + } else { + if (yych <= '\f') goto yy138; + if (yych <= 0x1F) goto yy78; + goto yy138; + } +yy80: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '"') goto yy135; + goto yy109; +yy81: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '&') { + if (yych == '"') goto yy129; + goto yy109; + } else { + if (yych <= '\'') goto yy131; + if (yych == 'R') goto yy128; + goto yy109; + } +yy82: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + goto yy109; +yy83: + yyaccept = 5; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'U') goto yy100; + if (yych == 'u') goto yy98; + goto yy78; +yy84: + ++YYCURSOR; + yych = *YYCURSOR; + goto yy97; +yy85: +#line 319 "cpp.re" + { BOOST_WAVE_RET(T_SPACE); } +#line 766 "cpp_re.inc" +yy86: + yych = *++YYCURSOR; + goto yy97; +yy87: + ++YYCURSOR; +yy88: +#line 322 "cpp.re" + { + s->line++; + cursor.column = 1; + BOOST_WAVE_RET(T_NEWLINE); + } +#line 779 "cpp_re.inc" +yy89: + yych = *++YYCURSOR; + if (yych == '\n') goto yy95; + goto yy88; +yy90: + ++YYCURSOR; +#line 329 "cpp.re" + { + if (s->eof && cursor != s->eof) + { + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_error, + "invalid character '\\000' in input stream"); + } + BOOST_WAVE_RET(T_EOF); + } +#line 796 "cpp_re.inc" +yy92: + yych = *++YYCURSOR; + goto yy78; +yy93: + ++YYCURSOR; +#line 342 "cpp.re" + { + // flag the error + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_error, + "invalid character '\\%03o' in input stream", *--YYCURSOR); + } +#line 809 "cpp_re.inc" +yy95: + yych = *++YYCURSOR; + goto yy88; +yy96: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy97: + if (yybm[256+yych] & 16) { + goto yy96; + } + goto yy85; +yy98: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy125; + } else { + if (yych <= 'F') goto yy125; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy125; + } +yy99: + YYCURSOR = YYMARKER; + if (yyaccept <= 56) { + if (yyaccept <= 28) { + if (yyaccept <= 14) { + if (yyaccept <= 7) { + if (yyaccept <= 3) { + if (yyaccept <= 1) { + if (yyaccept <= 0) { + goto yy5; + } else { + goto yy9; + } + } else { + if (yyaccept <= 2) { + goto yy32; + } else { + goto yy46; + } + } + } else { + if (yyaccept <= 5) { + if (yyaccept <= 4) { + goto yy65; + } else { + goto yy78; + } + } else { + if (yyaccept <= 6) { + goto yy142; + } else { + goto yy192; + } + } + } + } else { + if (yyaccept <= 11) { + if (yyaccept <= 9) { + if (yyaccept <= 8) { + goto yy251; + } else { + goto yy255; + } + } else { + if (yyaccept <= 10) { + goto yy291; + } else { + goto yy306; + } + } + } else { + if (yyaccept <= 13) { + if (yyaccept <= 12) { + goto yy401; + } else { + goto yy429; + } + } else { + goto yy433; + } + } + } + } else { + if (yyaccept <= 21) { + if (yyaccept <= 18) { + if (yyaccept <= 16) { + if (yyaccept <= 15) { + goto yy437; + } else { + goto yy468; + } + } else { + if (yyaccept <= 17) { + goto yy474; + } else { + goto yy482; + } + } + } else { + if (yyaccept <= 20) { + if (yyaccept <= 19) { + goto yy490; + } else { + goto yy495; + } + } else { + goto yy500; + } + } + } else { + if (yyaccept <= 25) { + if (yyaccept <= 23) { + if (yyaccept <= 22) { + goto yy503; + } else { + goto yy513; + } + } else { + if (yyaccept <= 24) { + goto yy519; + } else { + goto yy522; + } + } + } else { + if (yyaccept <= 27) { + if (yyaccept <= 26) { + goto yy529; + } else { + goto yy536; + } + } else { + goto yy538; + } + } + } + } + } else { + if (yyaccept <= 42) { + if (yyaccept <= 35) { + if (yyaccept <= 32) { + if (yyaccept <= 30) { + if (yyaccept <= 29) { + goto yy540; + } else { + goto yy542; + } + } else { + if (yyaccept <= 31) { + goto yy548; + } else { + goto yy554; + } + } + } else { + if (yyaccept <= 34) { + if (yyaccept <= 33) { + goto yy564; + } else { + goto yy566; + } + } else { + goto yy572; + } + } + } else { + if (yyaccept <= 39) { + if (yyaccept <= 37) { + if (yyaccept <= 36) { + goto yy579; + } else { + goto yy587; + } + } else { + if (yyaccept <= 38) { + goto yy590; + } else { + goto yy603; + } + } + } else { + if (yyaccept <= 41) { + if (yyaccept <= 40) { + goto yy605; + } else { + goto yy608; + } + } else { + goto yy611; + } + } + } + } else { + if (yyaccept <= 49) { + if (yyaccept <= 46) { + if (yyaccept <= 44) { + if (yyaccept <= 43) { + goto yy613; + } else { + goto yy619; + } + } else { + if (yyaccept <= 45) { + goto yy628; + } else { + goto yy630; + } + } + } else { + if (yyaccept <= 48) { + if (yyaccept <= 47) { + goto yy637; + } else { + goto yy646; + } + } else { + goto yy652; + } + } + } else { + if (yyaccept <= 53) { + if (yyaccept <= 51) { + if (yyaccept <= 50) { + goto yy656; + } else { + goto yy663; + } + } else { + if (yyaccept <= 52) { + goto yy669; + } else { + goto yy675; + } + } + } else { + if (yyaccept <= 55) { + if (yyaccept <= 54) { + goto yy679; + } else { + goto yy683; + } + } else { + goto yy691; + } + } + } + } + } + } else { + if (yyaccept <= 85) { + if (yyaccept <= 71) { + if (yyaccept <= 64) { + if (yyaccept <= 60) { + if (yyaccept <= 58) { + if (yyaccept <= 57) { + goto yy705; + } else { + goto yy711; + } + } else { + if (yyaccept <= 59) { + goto yy718; + } else { + goto yy727; + } + } + } else { + if (yyaccept <= 62) { + if (yyaccept <= 61) { + goto yy732; + } else { + goto yy735; + } + } else { + if (yyaccept <= 63) { + goto yy739; + } else { + goto yy746; + } + } + } + } else { + if (yyaccept <= 68) { + if (yyaccept <= 66) { + if (yyaccept <= 65) { + goto yy756; + } else { + goto yy759; + } + } else { + if (yyaccept <= 67) { + goto yy763; + } else { + goto yy769; + } + } + } else { + if (yyaccept <= 70) { + if (yyaccept <= 69) { + goto yy771; + } else { + goto yy779; + } + } else { + goto yy786; + } + } + } + } else { + if (yyaccept <= 78) { + if (yyaccept <= 75) { + if (yyaccept <= 73) { + if (yyaccept <= 72) { + goto yy790; + } else { + goto yy792; + } + } else { + if (yyaccept <= 74) { + goto yy797; + } else { + goto yy801; + } + } + } else { + if (yyaccept <= 77) { + if (yyaccept <= 76) { + goto yy806; + } else { + goto yy810; + } + } else { + goto yy819; + } + } + } else { + if (yyaccept <= 82) { + if (yyaccept <= 80) { + if (yyaccept <= 79) { + goto yy821; + } else { + goto yy825; + } + } else { + if (yyaccept <= 81) { + goto yy829; + } else { + goto yy838; + } + } + } else { + if (yyaccept <= 84) { + if (yyaccept <= 83) { + goto yy843; + } else { + goto yy848; + } + } else { + goto yy851; + } + } + } + } + } else { + if (yyaccept <= 99) { + if (yyaccept <= 92) { + if (yyaccept <= 89) { + if (yyaccept <= 87) { + if (yyaccept <= 86) { + goto yy854; + } else { + goto yy857; + } + } else { + if (yyaccept <= 88) { + goto yy869; + } else { + goto yy874; + } + } + } else { + if (yyaccept <= 91) { + if (yyaccept <= 90) { + goto yy881; + } else { + goto yy886; + } + } else { + goto yy892; + } + } + } else { + if (yyaccept <= 96) { + if (yyaccept <= 94) { + if (yyaccept <= 93) { + goto yy901; + } else { + goto yy908; + } + } else { + if (yyaccept <= 95) { + goto yy910; + } else { + goto yy916; + } + } + } else { + if (yyaccept <= 98) { + if (yyaccept <= 97) { + goto yy921; + } else { + goto yy925; + } + } else { + goto yy928; + } + } + } + } else { + if (yyaccept <= 106) { + if (yyaccept <= 103) { + if (yyaccept <= 101) { + if (yyaccept <= 100) { + goto yy934; + } else { + goto yy938; + } + } else { + if (yyaccept <= 102) { + goto yy943; + } else { + goto yy945; + } + } + } else { + if (yyaccept <= 105) { + if (yyaccept <= 104) { + goto yy952; + } else { + goto yy955; + } + } else { + goto yy960; + } + } + } else { + if (yyaccept <= 110) { + if (yyaccept <= 108) { + if (yyaccept <= 107) { + goto yy963; + } else { + goto yy970; + } + } else { + if (yyaccept <= 109) { + goto yy972; + } else { + goto yy974; + } + } + } else { + if (yyaccept <= 112) { + if (yyaccept <= 111) { + goto yy978; + } else { + goto yy985; + } + } else { + goto yy987; + } + } + } + } + } + } +yy100: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy101; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy101: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy102; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy102: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy103; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy103: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy104; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy104: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy105; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy105: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy106; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy106: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy107; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy107: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy108; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy108: + yyaccept = 1; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy109: + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych != '\\') goto yy9; +yy110: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == 'U') goto yy114; + if (yych == 'u') goto yy113; + goto yy99; +yy111: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych != '?') goto yy99; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '/') goto yy110; + goto yy99; +yy113: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy122; + goto yy99; + } else { + if (yych <= 'F') goto yy122; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy122; + goto yy99; + } +yy114: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy115; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy115: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy116; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy116: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy117; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy117: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy118; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy118: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy119; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy119: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy120; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy120: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy121; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy121: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy108; + goto yy99; + } else { + if (yych <= 'F') goto yy108; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy108; + goto yy99; + } +yy122: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy123; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy123: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy124; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy124: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy108; + goto yy99; + } else { + if (yych <= 'F') goto yy108; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy108; + goto yy99; + } +yy125: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy126; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy126: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy127; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy127: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy108; + goto yy99; + } else { + if (yych <= 'F') goto yy108; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy108; + goto yy99; + } +yy128: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '"') goto yy133; + goto yy109; +yy129: + ++YYCURSOR; +#line 274 "cpp.re" + { + if (s->act_in_cpp0x_mode) + goto extstringlit; + --YYCURSOR; + BOOST_WAVE_RET(T_IDENTIFIER); + } +#line 1591 "cpp_re.inc" +yy131: + ++YYCURSOR; +#line 266 "cpp.re" + { + if (s->act_in_cpp0x_mode) + goto extcharlit; + --YYCURSOR; + BOOST_WAVE_RET(T_IDENTIFIER); + } +#line 1601 "cpp_re.inc" +yy133: + ++YYCURSOR; +#line 282 "cpp.re" + { + if (s->act_in_cpp0x_mode) + goto extrawstringlit; + --YYCURSOR; + BOOST_WAVE_RET(T_IDENTIFIER); + } +#line 1611 "cpp_re.inc" +yy135: + ++YYCURSOR; +#line 258 "cpp.re" + { + if (s->act_in_cpp0x_mode) + goto extrawstringlit; + --YYCURSOR; + BOOST_WAVE_RET(T_IDENTIFIER); + } +#line 1621 "cpp_re.inc" +yy137: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy138: + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych >= '\\') goto yy140; +yy139: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych <= '[') goto yy152; +yy140: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy137; + goto yy99; + } else { + if (yych <= '\'') goto yy137; + if (yych <= '/') goto yy99; + goto yy147; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy145; + goto yy99; + } else { + if (yych <= 'U') goto yy144; + if (yych == '\\') goto yy137; + goto yy99; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy137; + if (yych <= 'e') goto yy99; + goto yy137; + } else { + if (yych == 'n') goto yy137; + if (yych <= 'q') goto yy99; + goto yy137; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy99; + if (yych <= 't') goto yy137; + goto yy143; + } else { + if (yych <= 'v') goto yy137; + if (yych == 'x') goto yy146; + goto yy99; + } + } + } +yy141: + ++YYCURSOR; +yy142: +#line 255 "cpp.re" + { BOOST_WAVE_RET(T_STRINGLIT); } +#line 1695 "cpp_re.inc" +yy143: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy178; + goto yy99; + } else { + if (yych <= 'F') goto yy178; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy178; + goto yy99; + } +yy144: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy171; + goto yy99; + } else { + if (yych <= 'F') goto yy171; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy171; + goto yy99; + } +yy145: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych <= '[') goto yy151; + goto yy140; +yy146: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 128) { + goto yy149; + } + goto yy99; +yy147: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '"') { + if (yych <= '\n') { + if (yych == '\t') goto yy137; + goto yy99; + } else { + if (yych <= '\f') goto yy137; + if (yych <= 0x1F) goto yy99; + if (yych <= '!') goto yy137; + goto yy141; + } + } else { + if (yych <= '>') { + if (yych <= '/') goto yy137; + if (yych >= '8') goto yy137; + } else { + if (yych <= '?') goto yy139; + if (yych == '\\') goto yy140; + goto yy137; + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych <= '[') goto yy139; + goto yy140; +yy149: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 128) { + goto yy149; + } + if (yych <= '!') { + if (yych <= '\n') { + if (yych == '\t') goto yy137; + goto yy99; + } else { + if (yych <= '\f') goto yy137; + if (yych <= 0x1F) goto yy99; + goto yy137; + } + } else { + if (yych <= '?') { + if (yych <= '"') goto yy141; + if (yych <= '>') goto yy137; + goto yy139; + } else { + if (yych == '\\') goto yy140; + goto yy137; + } + } +yy151: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych >= '\\') goto yy140; +yy152: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 1) { + goto yy152; + } + if (yych <= '!') { + if (yych <= '\n') { + if (yych == '\t') goto yy137; + goto yy99; + } else { + if (yych <= '\f') goto yy137; + if (yych <= 0x1F) goto yy99; + goto yy137; + } + } else { + if (yych <= '/') { + if (yych <= '"') goto yy141; + if (yych <= '.') goto yy137; + } else { + if (yych == '\\') goto yy140; + goto yy137; + } + } +yy154: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 2) { + goto yy154; + } + if (yych <= '7') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy158; + if (yych <= '/') goto yy137; + goto yy147; + } + } + } else { + if (yych <= 'U') { + if (yych == '?') goto yy159; + if (yych <= 'T') goto yy137; + goto yy157; + } else { + if (yych <= 'u') { + if (yych <= 't') goto yy137; + } else { + if (yych == 'x') goto yy149; + goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + goto yy168; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + goto yy168; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych <= 'f') goto yy168; + goto yy137; + } + } + } +yy157: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + goto yy161; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + goto yy161; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych <= 'f') goto yy161; + goto yy137; + } + } + } +yy158: + yyaccept = 6; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy142; + if (yych <= '"') goto yy141; + if (yych <= '[') goto yy139; + goto yy140; +yy159: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych >= '\\') goto yy140; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 1) { + goto yy152; + } + if (yych <= '!') { + if (yych <= '\n') { + if (yych == '\t') goto yy137; + goto yy99; + } else { + if (yych <= '\f') goto yy137; + if (yych <= 0x1F) goto yy99; + goto yy137; + } + } else { + if (yych <= '/') { + if (yych <= '"') goto yy141; + if (yych <= '.') goto yy137; + goto yy154; + } else { + if (yych == '\\') goto yy140; + goto yy137; + } + } +yy161: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych <= '[') goto yy139; + goto yy140; +yy168: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy137; + if (yych <= '\n') goto yy99; + goto yy137; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy99; + goto yy137; + } else { + if (yych <= '"') goto yy141; + if (yych <= '/') goto yy137; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy139; + if (yych <= '@') goto yy137; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy137; + goto yy140; + } else { + if (yych <= '`') goto yy137; + if (yych >= 'g') goto yy137; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[256+yych] & 64) { + goto yy137; + } + if (yych <= '!') goto yy99; + if (yych <= '"') goto yy141; + if (yych <= '[') goto yy139; + goto yy140; +yy171: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy172; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy172: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy173; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy173: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy174; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy174: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy175; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy175: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy176; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy176: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy177; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy177: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy137; + goto yy99; + } else { + if (yych <= 'F') goto yy137; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy137; + goto yy99; + } +yy178: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy179; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy179: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy180; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy180: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy137; + goto yy99; + } else { + if (yych <= 'F') goto yy137; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy137; + goto yy99; + } +yy181: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy182: + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych >= '\\') goto yy184; +yy183: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych <= '[') goto yy196; +yy184: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy181; + goto yy99; + } else { + if (yych <= '\'') goto yy181; + if (yych <= '/') goto yy99; + goto yy189; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy187; + goto yy99; + } else { + if (yych <= 'U') goto yy186; + if (yych == '\\') goto yy181; + goto yy99; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy181; + if (yych <= 'e') goto yy99; + goto yy181; + } else { + if (yych == 'n') goto yy181; + if (yych <= 'q') goto yy99; + goto yy181; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy99; + if (yych <= 't') goto yy181; + } else { + if (yych <= 'v') goto yy181; + if (yych == 'x') goto yy188; + goto yy99; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy222; + goto yy99; + } else { + if (yych <= 'F') goto yy222; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy222; + goto yy99; + } +yy186: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy215; + goto yy99; + } else { + if (yych <= 'F') goto yy215; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy215; + goto yy99; + } +yy187: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych <= '[') goto yy195; + goto yy184; +yy188: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy193; + goto yy99; + } else { + if (yych <= 'F') goto yy193; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy193; + goto yy99; + } +yy189: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\'') { + if (yych <= '\n') { + if (yych == '\t') goto yy181; + goto yy99; + } else { + if (yych <= '\f') goto yy181; + if (yych <= 0x1F) goto yy99; + if (yych <= '&') goto yy181; + goto yy191; + } + } else { + if (yych <= '>') { + if (yych <= '/') goto yy181; + if (yych >= '8') goto yy181; + } else { + if (yych <= '?') goto yy183; + if (yych == '\\') goto yy184; + goto yy181; + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych <= '[') goto yy183; + goto yy184; +yy191: + ++YYCURSOR; +yy192: +#line 252 "cpp.re" + { BOOST_WAVE_RET(T_CHARLIT); } +#line 2542 "cpp_re.inc" +yy193: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + goto yy193; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + goto yy193; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych <= 'f') goto yy193; + goto yy181; + } + } + } +yy195: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych >= '\\') goto yy184; +yy196: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\'') { + if (yych <= '\n') { + if (yych == '\t') goto yy181; + goto yy99; + } else { + if (yych <= '\f') goto yy181; + if (yych <= 0x1F) goto yy99; + if (yych <= '&') goto yy181; + goto yy191; + } + } else { + if (yych <= '>') { + if (yych != '/') goto yy181; + } else { + if (yych <= '?') goto yy196; + if (yych == '\\') goto yy184; + goto yy181; + } + } +yy198: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '>') { + if (yych <= 0x1F) { + if (yych <= '\t') { + if (yych <= 0x08) goto yy99; + goto yy181; + } else { + if (yych <= '\n') goto yy99; + if (yych <= '\f') goto yy181; + goto yy99; + } + } else { + if (yych <= '\'') { + if (yych <= '&') goto yy181; + goto yy202; + } else { + if (yych <= '/') goto yy181; + if (yych <= '7') goto yy189; + goto yy181; + } + } + } else { + if (yych <= '\\') { + if (yych <= 'T') { + if (yych <= '?') goto yy203; + goto yy181; + } else { + if (yych <= 'U') goto yy201; + if (yych <= '[') goto yy181; + goto yy198; + } + } else { + if (yych <= 'u') { + if (yych <= 't') goto yy181; + } else { + if (yych == 'x') goto yy193; + goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + goto yy212; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + goto yy212; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych <= 'f') goto yy212; + goto yy181; + } + } + } +yy201: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + goto yy205; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + goto yy205; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych <= 'f') goto yy205; + goto yy181; + } + } + } +yy202: + yyaccept = 7; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy192; + if (yych <= '\'') goto yy191; + if (yych <= '[') goto yy183; + goto yy184; +yy203: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych >= '\\') goto yy184; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\'') { + if (yych <= '\n') { + if (yych == '\t') goto yy181; + goto yy99; + } else { + if (yych <= '\f') goto yy181; + if (yych <= 0x1F) goto yy99; + if (yych <= '&') goto yy181; + goto yy191; + } + } else { + if (yych <= '>') { + if (yych == '/') goto yy198; + goto yy181; + } else { + if (yych <= '?') goto yy196; + if (yych == '\\') goto yy184; + goto yy181; + } + } +yy205: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych <= '[') goto yy183; + goto yy184; +yy212: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy181; + if (yych <= '\n') goto yy99; + goto yy181; + } else { + if (yych <= '&') { + if (yych <= 0x1F) goto yy99; + goto yy181; + } else { + if (yych <= '\'') goto yy191; + if (yych <= '/') goto yy181; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy183; + if (yych <= '@') goto yy181; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy181; + goto yy184; + } else { + if (yych <= '`') goto yy181; + if (yych >= 'g') goto yy181; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 4) { + goto yy181; + } + if (yych <= '&') goto yy99; + if (yych <= '\'') goto yy191; + if (yych <= '[') goto yy183; + goto yy184; +yy215: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy216; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy216: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy217; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy217: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy218; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy218: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy219; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy219: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy220; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy220: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy221; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy221: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy181; + goto yy99; + } else { + if (yych <= 'F') goto yy181; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy181; + goto yy99; + } +yy222: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy223; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy223: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych >= ':') goto yy99; + } else { + if (yych <= 'F') goto yy224; + if (yych <= '`') goto yy99; + if (yych >= 'g') goto yy99; + } +yy224: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy99; + if (yych <= '9') goto yy181; + goto yy99; + } else { + if (yych <= 'F') goto yy181; + if (yych <= '`') goto yy99; + if (yych <= 'f') goto yy181; + goto yy99; + } +yy225: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '"') goto yy135; + goto yy109; +yy226: + yych = *++YYCURSOR; + if (yych == '\'') goto yy99; + goto yy182; +yy227: + ++YYCURSOR; +#line 227 "cpp.re" + { BOOST_WAVE_RET(T_GREATEREQUAL); } +#line 3175 "cpp_re.inc" +yy229: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy231; +#line 220 "cpp.re" + { BOOST_WAVE_RET(T_SHIFTRIGHT); } +#line 3181 "cpp_re.inc" +yy231: + ++YYCURSOR; +#line 221 "cpp.re" + { BOOST_WAVE_RET(T_SHIFTRIGHTASSIGN); } +#line 3186 "cpp_re.inc" +yy233: + ++YYCURSOR; +#line 223 "cpp.re" + { BOOST_WAVE_RET(T_EQUAL); } +#line 3191 "cpp_re.inc" +yy235: + ++YYCURSOR; +#line 224 "cpp.re" + { BOOST_WAVE_RET(T_NOTEQUAL); } +#line 3196 "cpp_re.inc" +yy237: + yych = *++YYCURSOR; + if (yych == '?') goto yy242; + goto yy99; +yy238: + ++YYCURSOR; +#line 230 "cpp.re" + { BOOST_WAVE_RET(T_OROR); } +#line 3205 "cpp_re.inc" +yy240: + ++YYCURSOR; +#line 216 "cpp.re" + { BOOST_WAVE_RET(T_ORASSIGN); } +#line 3210 "cpp_re.inc" +yy242: + yych = *++YYCURSOR; + if (yych != '!') goto yy99; + ++YYCURSOR; +#line 232 "cpp.re" + { BOOST_WAVE_RET(T_OROR_TRIGRAPH); } +#line 3217 "cpp_re.inc" +yy245: + ++YYCURSOR; +#line 228 "cpp.re" + { BOOST_WAVE_RET(T_ANDAND); } +#line 3222 "cpp_re.inc" +yy247: + ++YYCURSOR; +#line 214 "cpp.re" + { BOOST_WAVE_RET(T_ANDASSIGN); } +#line 3227 "cpp_re.inc" +yy249: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 8; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') { + if (yych <= '/') { + if (yych == '$') goto yy108; + } else { + if (yych <= '9') goto yy108; + if (yych == '?') goto yy111; + } + } else { + if (yych <= '^') { + if (yych <= 'Z') goto yy108; + if (yych == '\\') goto yy110; + } else { + if (yych <= '_') goto yy252; + if (yych <= '`') goto yy251; + if (yych <= 'z') goto yy108; + } + } +yy251: +#line 192 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XOR_ALT); } +#line 3254 "cpp_re.inc" +yy252: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'q') goto yy109; + yyaccept = 9; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy255: +#line 212 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_XORASSIGN_ALT); } +#line 3272 "cpp_re.inc" +yy256: + ++YYCURSOR; +#line 211 "cpp.re" + { BOOST_WAVE_RET(T_XORASSIGN); } +#line 3277 "cpp_re.inc" +yy258: + ++YYCURSOR; +#line 208 "cpp.re" + { BOOST_WAVE_RET(T_STARASSIGN); } +#line 3282 "cpp_re.inc" +yy260: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '*') goto yy266; +#line 248 "cpp.re" + { BOOST_WAVE_RET(T_ARROW); } +#line 3288 "cpp_re.inc" +yy262: + ++YYCURSOR; +#line 236 "cpp.re" + { BOOST_WAVE_RET(T_MINUSMINUS); } +#line 3293 "cpp_re.inc" +yy264: + ++YYCURSOR; +#line 207 "cpp.re" + { BOOST_WAVE_RET(T_MINUSASSIGN); } +#line 3298 "cpp_re.inc" +yy266: + ++YYCURSOR; +#line 239 "cpp.re" + { + if (s->act_in_c99_mode) { + --YYCURSOR; + BOOST_WAVE_RET(T_ARROW); + } + else { + BOOST_WAVE_RET(T_ARROWSTAR); + } + } +#line 3311 "cpp_re.inc" +yy268: + ++YYCURSOR; +#line 235 "cpp.re" + { BOOST_WAVE_RET(T_PLUSPLUS); } +#line 3316 "cpp_re.inc" +yy270: + ++YYCURSOR; +#line 206 "cpp.re" + { BOOST_WAVE_RET(T_PLUSASSIGN); } +#line 3321 "cpp_re.inc" +yy272: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 12) YYFILL(12); + yych = *YYCURSOR; +yy273: + if (yych <= 'h') { + if (yych <= ' ') { + if (yych <= '\n') { + if (yych == '\t') goto yy272; + goto yy99; + } else { + if (yych <= '\f') goto yy272; + if (yych <= 0x1F) goto yy99; + goto yy272; + } + } else { + if (yych <= 'c') { + if (yych != '/') goto yy99; + } else { + if (yych <= 'd') goto yy281; + if (yych <= 'e') goto yy275; + goto yy99; + } + } + } else { + if (yych <= 'q') { + if (yych <= 'l') { + if (yych <= 'i') goto yy282; + if (yych <= 'k') goto yy99; + goto yy279; + } else { + if (yych == 'p') goto yy278; + goto yy99; + } + } else { + if (yych <= 'u') { + if (yych <= 'r') goto yy276; + if (yych <= 't') goto yy99; + goto yy280; + } else { + if (yych == 'w') goto yy277; + goto yy99; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '*') goto yy389; + goto yy99; +yy275: + yych = *++YYCURSOR; + if (yych <= 'm') { + if (yych == 'l') goto yy365; + goto yy99; + } else { + if (yych <= 'n') goto yy366; + if (yych == 'r') goto yy367; + goto yy99; + } +yy276: + yych = *++YYCURSOR; + if (yych == 'e') goto yy359; + goto yy99; +yy277: + yych = *++YYCURSOR; + if (yych == 'a') goto yy352; + goto yy99; +yy278: + yych = *++YYCURSOR; + if (yych == 'r') goto yy346; + goto yy99; +yy279: + yych = *++YYCURSOR; + if (yych == 'i') goto yy342; + goto yy99; +yy280: + yych = *++YYCURSOR; + if (yych == 'n') goto yy337; + goto yy99; +yy281: + yych = *++YYCURSOR; + if (yych == 'e') goto yy331; + goto yy99; +yy282: + yych = *++YYCURSOR; + if (yych == 'f') goto yy290; + if (yych == 'n') goto yy289; + goto yy99; +yy283: + yych = *++YYCURSOR; + if (yych == '?') goto yy286; + goto yy99; +yy284: + ++YYCURSOR; +#line 153 "cpp.re" + { BOOST_WAVE_RET(T_POUND_POUND); } +#line 3419 "cpp_re.inc" +yy286: + yych = *++YYCURSOR; + if (yych != '=') goto yy99; + ++YYCURSOR; +#line 154 "cpp.re" + { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); } +#line 3426 "cpp_re.inc" +yy289: + yych = *++YYCURSOR; + if (yych == 'c') goto yy301; + goto yy99; +yy290: + yyaccept = 10; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy293; + if (yych == 'n') goto yy292; +yy291: +#line 301 "cpp.re" + { BOOST_WAVE_RET(T_PP_IF); } +#line 3439 "cpp_re.inc" +yy292: + yych = *++YYCURSOR; + if (yych == 'd') goto yy297; + goto yy99; +yy293: + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + yych = *++YYCURSOR; + if (yych != 'f') goto yy99; + ++YYCURSOR; +#line 302 "cpp.re" + { BOOST_WAVE_RET(T_PP_IFDEF); } +#line 3452 "cpp_re.inc" +yy297: + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + yych = *++YYCURSOR; + if (yych != 'f') goto yy99; + ++YYCURSOR; +#line 303 "cpp.re" + { BOOST_WAVE_RET(T_PP_IFNDEF); } +#line 3461 "cpp_re.inc" +yy301: + yych = *++YYCURSOR; + if (yych != 'l') goto yy99; + yych = *++YYCURSOR; + if (yych != 'u') goto yy99; + yych = *++YYCURSOR; + if (yych != 'd') goto yy99; + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + yyaccept = 11; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '_') goto yy307; + goto yy309; +yy306: +#line 299 "cpp.re" + { BOOST_WAVE_RET(T_PP_INCLUDE); } +#line 3478 "cpp_re.inc" +yy307: + yych = *++YYCURSOR; + if (yych == 'n') goto yy328; + goto yy99; +yy308: + yyaccept = 11; + YYMARKER = ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; +yy309: + if (yych <= ' ') { + if (yych <= '\n') { + if (yych == '\t') goto yy308; + goto yy306; + } else { + if (yych <= '\f') goto yy308; + if (yych <= 0x1F) goto yy306; + goto yy308; + } + } else { + if (yych <= '.') { + if (yych == '"') goto yy312; + goto yy306; + } else { + if (yych <= '/') goto yy310; + if (yych == '<') goto yy311; + goto yy306; + } + } +yy310: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '*') goto yy321; + goto yy99; +yy311: + yych = *++YYCURSOR; + if (yych == '>') goto yy99; + goto yy318; +yy312: + yych = *++YYCURSOR; + if (yych == '"') goto yy99; + goto yy314; +yy313: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy314: + if (yybm[0+yych] & 8) { + goto yy313; + } + if (yych <= '!') goto yy99; + ++YYCURSOR; +#line 296 "cpp.re" + { BOOST_WAVE_RET(T_PP_QHEADER); } +#line 3534 "cpp_re.inc" +yy317: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy318: + if (yybm[0+yych] & 16) { + goto yy317; + } + if (yych <= '=') goto yy99; + ++YYCURSOR; +#line 293 "cpp.re" + { BOOST_WAVE_RET(T_PP_HHEADER); } +#line 3547 "cpp_re.inc" +yy321: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy321; + } + if (yych == '\r') goto yy323; + if (yych <= ')') goto yy99; + goto yy325; +yy323: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy321; + } + if (yych == '\r') goto yy323; + if (yych <= ')') goto yy99; +yy325: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy325; + } + if (yych <= '\r') { + if (yych <= 0x08) goto yy99; + if (yych <= '\f') goto yy321; + } else { + if (yych <= 0x1F) goto yy99; + if (yych == '/') goto yy308; + goto yy321; + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy321; + } + if (yych == '\r') goto yy323; + if (yych <= ')') goto yy99; + goto yy325; +yy328: + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + yych = *++YYCURSOR; + if (yych != 'x') goto yy99; + yych = *++YYCURSOR; + if (yych == 't') goto yy308; + goto yy99; +yy331: + yych = *++YYCURSOR; + if (yych != 'f') goto yy99; + yych = *++YYCURSOR; + if (yych != 'i') goto yy99; + yych = *++YYCURSOR; + if (yych != 'n') goto yy99; + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + ++YYCURSOR; +#line 307 "cpp.re" + { BOOST_WAVE_RET(T_PP_DEFINE); } +#line 3611 "cpp_re.inc" +yy337: + yych = *++YYCURSOR; + if (yych != 'd') goto yy99; + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + yych = *++YYCURSOR; + if (yych != 'f') goto yy99; + ++YYCURSOR; +#line 308 "cpp.re" + { BOOST_WAVE_RET(T_PP_UNDEF); } +#line 3622 "cpp_re.inc" +yy342: + yych = *++YYCURSOR; + if (yych != 'n') goto yy99; + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + ++YYCURSOR; +#line 309 "cpp.re" + { BOOST_WAVE_RET(T_PP_LINE); } +#line 3631 "cpp_re.inc" +yy346: + yych = *++YYCURSOR; + if (yych != 'a') goto yy99; + yych = *++YYCURSOR; + if (yych != 'g') goto yy99; + yych = *++YYCURSOR; + if (yych != 'm') goto yy99; + yych = *++YYCURSOR; + if (yych != 'a') goto yy99; + ++YYCURSOR; +#line 311 "cpp.re" + { BOOST_WAVE_RET(T_PP_PRAGMA); } +#line 3644 "cpp_re.inc" +yy352: + yych = *++YYCURSOR; + if (yych != 'r') goto yy99; + yych = *++YYCURSOR; + if (yych != 'n') goto yy99; + yych = *++YYCURSOR; + if (yych != 'i') goto yy99; + yych = *++YYCURSOR; + if (yych != 'n') goto yy99; + yych = *++YYCURSOR; + if (yych != 'g') goto yy99; + ++YYCURSOR; +#line 313 "cpp.re" + { BOOST_WAVE_RET(T_PP_WARNING); } +#line 3659 "cpp_re.inc" +yy359: + yych = *++YYCURSOR; + if (yych != 'g') goto yy99; + yych = *++YYCURSOR; + if (yych != 'i') goto yy99; + yych = *++YYCURSOR; + if (yych != 'o') goto yy99; + yych = *++YYCURSOR; + if (yych != 'n') goto yy99; + ++YYCURSOR; +#line 315 "cpp.re" + { BOOST_WAVE_RET(T_MSEXT_PP_REGION); } +#line 3672 "cpp_re.inc" +yy365: + yych = *++YYCURSOR; + if (yych == 'i') goto yy383; + if (yych == 's') goto yy384; + goto yy99; +yy366: + yych = *++YYCURSOR; + if (yych == 'd') goto yy372; + goto yy99; +yy367: + yych = *++YYCURSOR; + if (yych != 'r') goto yy99; + yych = *++YYCURSOR; + if (yych != 'o') goto yy99; + yych = *++YYCURSOR; + if (yych != 'r') goto yy99; + ++YYCURSOR; +#line 310 "cpp.re" + { BOOST_WAVE_RET(T_PP_ERROR); } +#line 3692 "cpp_re.inc" +yy372: + yych = *++YYCURSOR; + if (yych == 'i') goto yy373; + if (yych == 'r') goto yy374; + goto yy99; +yy373: + yych = *++YYCURSOR; + if (yych == 'f') goto yy381; + goto yy99; +yy374: + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + yych = *++YYCURSOR; + if (yych != 'g') goto yy99; + yych = *++YYCURSOR; + if (yych != 'i') goto yy99; + yych = *++YYCURSOR; + if (yych != 'o') goto yy99; + yych = *++YYCURSOR; + if (yych != 'n') goto yy99; + ++YYCURSOR; +#line 316 "cpp.re" + { BOOST_WAVE_RET(T_MSEXT_PP_ENDREGION); } +#line 3716 "cpp_re.inc" +yy381: + ++YYCURSOR; +#line 306 "cpp.re" + { BOOST_WAVE_RET(T_PP_ENDIF); } +#line 3721 "cpp_re.inc" +yy383: + yych = *++YYCURSOR; + if (yych == 'f') goto yy387; + goto yy99; +yy384: + yych = *++YYCURSOR; + if (yych != 'e') goto yy99; + ++YYCURSOR; +#line 304 "cpp.re" + { BOOST_WAVE_RET(T_PP_ELSE); } +#line 3732 "cpp_re.inc" +yy387: + ++YYCURSOR; +#line 305 "cpp.re" + { BOOST_WAVE_RET(T_PP_ELIF); } +#line 3737 "cpp_re.inc" +yy389: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\r') { + if (yych <= 0x08) goto yy99; + if (yych <= '\f') goto yy389; + } else { + if (yych <= 0x1F) goto yy99; + if (yych == '*') goto yy393; + goto yy389; + } +yy391: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\r') { + if (yych <= 0x08) goto yy99; + if (yych <= '\f') goto yy389; + goto yy391; + } else { + if (yych <= 0x1F) goto yy99; + if (yych != '*') goto yy389; + } +yy393: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych <= 0x08) goto yy99; + if (yych <= '\f') goto yy389; + if (yych >= 0x0E) goto yy99; + } else { + if (yych <= '*') { + if (yych <= ')') goto yy389; + goto yy393; + } else { + if (yych == '/') goto yy272; + goto yy389; + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '\r') { + if (yych <= 0x08) goto yy99; + if (yych <= '\f') goto yy389; + goto yy391; + } else { + if (yych <= 0x1F) goto yy99; + if (yych == '*') goto yy393; + goto yy389; + } +yy396: + ++YYCURSOR; +#line 165 "cpp.re" + { + if (s->act_in_c99_mode) { + --YYCURSOR; + BOOST_WAVE_RET(T_COLON); + } + else { + BOOST_WAVE_RET(T_COLON_COLON); + } + } +#line 3803 "cpp_re.inc" +yy398: + ++YYCURSOR; +#line 149 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTBRACKET_ALT); } +#line 3808 "cpp_re.inc" +yy400: + yyaccept = 12; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'e') { + if (yych <= ' ') { + if (yych <= '\n') { + if (yych == '\t') goto yy273; + } else { + if (yych <= '\f') goto yy273; + if (yych >= ' ') goto yy273; + } + } else { + if (yych <= '.') { + if (yych == '%') goto yy406; + } else { + if (yych <= '/') goto yy273; + if (yych >= 'd') goto yy273; + } + } + } else { + if (yych <= 'p') { + if (yych <= 'k') { + if (yych == 'i') goto yy273; + } else { + if (yych <= 'l') goto yy273; + if (yych >= 'p') goto yy273; + } + } else { + if (yych <= 't') { + if (yych == 'r') goto yy273; + } else { + if (yych == 'v') goto yy401; + if (yych <= 'w') goto yy273; + } + } + } +yy401: +#line 151 "cpp.re" + { BOOST_WAVE_RET(T_POUND_ALT); } +#line 3848 "cpp_re.inc" +yy402: + ++YYCURSOR; +#line 210 "cpp.re" + { BOOST_WAVE_RET(T_PERCENTASSIGN); } +#line 3853 "cpp_re.inc" +yy404: + ++YYCURSOR; +#line 143 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTBRACE_ALT); } +#line 3858 "cpp_re.inc" +yy406: + yych = *++YYCURSOR; + if (yych != ':') goto yy99; + ++YYCURSOR; +#line 157 "cpp.re" + { BOOST_WAVE_RET(T_POUND_POUND_ALT); } +#line 3865 "cpp_re.inc" +yy409: + ++YYCURSOR; +#line 226 "cpp.re" + { BOOST_WAVE_RET(T_LESSEQUAL); } +#line 3870 "cpp_re.inc" +yy411: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy417; +#line 219 "cpp.re" + { BOOST_WAVE_RET(T_SHIFTLEFT); } +#line 3876 "cpp_re.inc" +yy413: + ++YYCURSOR; +#line 146 "cpp.re" + { BOOST_WAVE_RET(T_LEFTBRACKET_ALT); } +#line 3881 "cpp_re.inc" +yy415: + ++YYCURSOR; +#line 140 "cpp.re" + { BOOST_WAVE_RET(T_LEFTBRACE_ALT); } +#line 3886 "cpp_re.inc" +yy417: + ++YYCURSOR; +#line 222 "cpp.re" + { BOOST_WAVE_RET(T_SHIFTLEFTASSIGN); } +#line 3891 "cpp_re.inc" +yy419: + yych = *++YYCURSOR; + switch (yych) { + case '!': goto yy432; + case '\'': goto yy430; + case '(': goto yy424; + case ')': goto yy426; + case '-': goto yy434; + case '/': goto yy436; + case '<': goto yy420; + case '=': goto yy428; + case '>': goto yy422; + default: goto yy99; + } +yy420: + ++YYCURSOR; +#line 139 "cpp.re" + { BOOST_WAVE_RET(T_LEFTBRACE_TRIGRAPH); } +#line 3910 "cpp_re.inc" +yy422: + ++YYCURSOR; +#line 142 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTBRACE_TRIGRAPH); } +#line 3915 "cpp_re.inc" +yy424: + ++YYCURSOR; +#line 145 "cpp.re" + { BOOST_WAVE_RET(T_LEFTBRACKET_TRIGRAPH); } +#line 3920 "cpp_re.inc" +yy426: + ++YYCURSOR; +#line 148 "cpp.re" + { BOOST_WAVE_RET(T_RIGHTBRACKET_TRIGRAPH); } +#line 3925 "cpp_re.inc" +yy428: + yyaccept = 13; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'c') { + if (yych <= ' ') { + if (yych <= '\n') { + if (yych == '\t') goto yy273; + } else { + if (yych <= '\f') goto yy273; + if (yych >= ' ') goto yy273; + } + } else { + if (yych <= '.') { + if (yych == '#') goto yy449; + } else { + if (yych <= '/') goto yy273; + if (yych == '?') goto yy448; + } + } + } else { + if (yych <= 'p') { + if (yych <= 'i') { + if (yych <= 'e') goto yy273; + if (yych >= 'i') goto yy273; + } else { + if (yych == 'l') goto yy273; + if (yych >= 'p') goto yy273; + } + } else { + if (yych <= 't') { + if (yych == 'r') goto yy273; + } else { + if (yych == 'v') goto yy429; + if (yych <= 'w') goto yy273; + } + } + } +yy429: +#line 152 "cpp.re" + { BOOST_WAVE_RET(T_POUND_TRIGRAPH); } +#line 3966 "cpp_re.inc" +yy430: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '=') goto yy446; +#line 191 "cpp.re" + { BOOST_WAVE_RET(T_XOR_TRIGRAPH); } +#line 3972 "cpp_re.inc" +yy432: + yyaccept = 14; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '>') { + if (yych == '=') goto yy441; + } else { + if (yych <= '?') goto yy438; + if (yych == '|') goto yy439; + } +yy433: +#line 197 "cpp.re" + { BOOST_WAVE_RET(T_OR_TRIGRAPH); } +#line 3985 "cpp_re.inc" +yy434: + ++YYCURSOR; +#line 199 "cpp.re" + { BOOST_WAVE_RET(T_COMPL_TRIGRAPH); } +#line 3990 "cpp_re.inc" +yy436: + yyaccept = 15; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'U') goto yy100; + if (yych == 'u') goto yy98; +yy437: +#line 249 "cpp.re" + { BOOST_WAVE_RET(T_ANY_TRIGRAPH); } +#line 3999 "cpp_re.inc" +yy438: + yych = *++YYCURSOR; + if (yych == '?') goto yy443; + goto yy99; +yy439: + ++YYCURSOR; +#line 231 "cpp.re" + { BOOST_WAVE_RET(T_OROR_TRIGRAPH); } +#line 4008 "cpp_re.inc" +yy441: + ++YYCURSOR; +#line 218 "cpp.re" + { BOOST_WAVE_RET(T_ORASSIGN_TRIGRAPH); } +#line 4013 "cpp_re.inc" +yy443: + yych = *++YYCURSOR; + if (yych != '!') goto yy99; + ++YYCURSOR; +#line 234 "cpp.re" + { BOOST_WAVE_RET(T_OROR_TRIGRAPH); } +#line 4020 "cpp_re.inc" +yy446: + ++YYCURSOR; +#line 213 "cpp.re" + { BOOST_WAVE_RET(T_XORASSIGN_TRIGRAPH); } +#line 4025 "cpp_re.inc" +yy448: + yych = *++YYCURSOR; + if (yych == '?') goto yy451; + goto yy99; +yy449: + ++YYCURSOR; +#line 155 "cpp.re" + { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); } +#line 4034 "cpp_re.inc" +yy451: + yych = *++YYCURSOR; + if (yych != '=') goto yy99; + ++YYCURSOR; +#line 156 "cpp.re" + { BOOST_WAVE_RET(T_POUND_POUND_TRIGRAPH); } +#line 4041 "cpp_re.inc" +yy454: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case 'a': goto yy455; + case 'b': goto yy456; + case 'c': goto yy457; + case 'd': goto yy458; + case 'e': goto yy507; + case 'f': goto yy505; + case 'i': goto yy504; + case 'l': goto yy508; + case 's': goto yy461; + case 't': goto yy506; + default: goto yy109; + } +yy455: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 's') goto yy501; + goto yy109; +yy456: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy496; + goto yy109; +yy457: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy491; + goto yy109; +yy458: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy483; + goto yy109; +yy459: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy475; + goto yy109; +yy460: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy469; + goto yy109; +yy461: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 16; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy468: +#line 130 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_STDCALL : T_IDENTIFIER); } +#line 4117 "cpp_re.inc" +yy469: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; +yy470: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 17; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy474: +#line 135 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INLINE : T_IDENTIFIER); } +#line 4142 "cpp_re.inc" +yy475: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 18; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy482: +#line 129 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FASTCALL : T_IDENTIFIER); } +#line 4172 "cpp_re.inc" +yy483: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 19; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy490: +#line 127 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_DECLSPEC : T_IDENTIFIER); } +#line 4202 "cpp_re.inc" +yy491: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 20; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy495: +#line 128 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_CDECL : T_IDENTIFIER); } +#line 4223 "cpp_re.inc" +yy496: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 21; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy500: +#line 126 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_BASED : T_IDENTIFIER); } +#line 4244 "cpp_re.inc" +yy501: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'm') goto yy109; + yyaccept = 22; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy503: +#line 136 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_ASM : T_IDENTIFIER); } +#line 4259 "cpp_re.inc" +yy504: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy530; + goto yy109; +yy505: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy475; + if (yych == 'i') goto yy523; + goto yy109; +yy506: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'r') goto yy520; + goto yy109; +yy507: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'x') goto yy514; + goto yy109; +yy508: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'v') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 23; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy513: +#line 134 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_LEAVE : T_IDENTIFIER); } +#line 4304 "cpp_re.inc" +yy514: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 24; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy519: +#line 132 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_EXCEPT : T_IDENTIFIER); } +#line 4328 "cpp_re.inc" +yy520: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'y') goto yy109; + yyaccept = 25; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy522: +#line 131 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_TRY : T_IDENTIFIER); } +#line 4343 "cpp_re.inc" +yy523: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'y') goto yy109; + yyaccept = 26; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy529: +#line 133 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_FINALLY : T_IDENTIFIER); } +#line 4370 "cpp_re.inc" +yy530: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'l') goto yy470; + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + switch (yych) { + case '1': goto yy532; + case '3': goto yy533; + case '6': goto yy534; + case '8': goto yy535; + default: goto yy109; + } +yy532: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '6') goto yy541; + goto yy109; +yy533: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '2') goto yy539; + goto yy109; +yy534: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '4') goto yy537; + goto yy109; +yy535: + yyaccept = 27; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy536: +#line 122 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT8 : T_IDENTIFIER); } +#line 4411 "cpp_re.inc" +yy537: + yyaccept = 28; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy538: +#line 125 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT64 : T_IDENTIFIER); } +#line 4423 "cpp_re.inc" +yy539: + yyaccept = 29; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy540: +#line 124 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT32 : T_IDENTIFIER); } +#line 4435 "cpp_re.inc" +yy541: + yyaccept = 30; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy542: +#line 123 "cpp.re" + { BOOST_WAVE_RET(s->enable_ms_extensions ? T_MSEXT_INT16 : T_IDENTIFIER); } +#line 4447 "cpp_re.inc" +yy543: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'h') goto yy549; + goto yy109; +yy544: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 31; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy548: +#line 120 "cpp.re" + { BOOST_WAVE_RET(T_WHILE); } +#line 4473 "cpp_re.inc" +yy549: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 32; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy554: +#line 119 "cpp.re" + { BOOST_WAVE_RET(T_WCHART); } +#line 4497 "cpp_re.inc" +yy555: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'r') goto yy567; + goto yy109; +yy556: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy557; + if (yych == 'l') goto yy558; + goto yy109; +yy557: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy565; + goto yy109; +yy558: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 33; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy564: +#line 118 "cpp.re" + { BOOST_WAVE_RET(T_VOLATILE); } +#line 4540 "cpp_re.inc" +yy565: + yyaccept = 34; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy566: +#line 117 "cpp.re" + { BOOST_WAVE_RET(T_VOID); } +#line 4552 "cpp_re.inc" +yy567: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'u') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 35; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy572: +#line 116 "cpp.re" + { BOOST_WAVE_RET(T_VIRTUAL); } +#line 4576 "cpp_re.inc" +yy573: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '"') goto yy129; + if (yych == 'R') goto yy128; + goto yy109; +yy574: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy580; + if (yych == 's') goto yy581; + goto yy109; +yy575: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'g') goto yy109; + yyaccept = 36; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy579: +#line 115 "cpp.re" + { BOOST_WAVE_RET(T_USING); } +#line 4609 "cpp_re.inc" +yy580: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy588; + goto yy109; +yy581: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'g') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 37; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy587: +#line 114 "cpp.re" + { BOOST_WAVE_RET(T_UNSIGNED); } +#line 4641 "cpp_re.inc" +yy588: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 38; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy590: +#line 113 "cpp.re" + { BOOST_WAVE_RET(T_UNION); } +#line 4656 "cpp_re.inc" +yy591: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'm') goto yy631; + goto yy109; +yy592: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy614; + if (yych == 'r') goto yy615; + goto yy109; +yy593: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'u') goto yy609; + if (yych == 'y') goto yy610; + goto yy109; +yy594: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'h') { + if (yych != 'd') goto yy109; + } else { + if (yych <= 'i') goto yy598; + if (yych == 'n') goto yy599; + goto yy109; + } + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy606; + goto yy109; +yy598: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy604; + goto yy109; +yy599: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'm') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 39; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy603: +#line 112 "cpp.re" + { BOOST_WAVE_RET(T_TYPENAME); } +#line 4719 "cpp_re.inc" +yy604: + yyaccept = 40; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy605: +#line 111 "cpp.re" + { BOOST_WAVE_RET(T_TYPEID); } +#line 4731 "cpp_re.inc" +yy606: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'f') goto yy109; + yyaccept = 41; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy608: +#line 110 "cpp.re" + { BOOST_WAVE_RET(T_TYPEDEF); } +#line 4746 "cpp_re.inc" +yy609: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy612; + goto yy109; +yy610: + yyaccept = 42; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy611: +#line 109 "cpp.re" + { BOOST_WAVE_RET(T_TRY); } +#line 4763 "cpp_re.inc" +yy612: + yyaccept = 43; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy613: +#line 108 "cpp.re" + { BOOST_WAVE_RET(T_TRUE); } +#line 4775 "cpp_re.inc" +yy614: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 's') goto yy629; + goto yy109; +yy615: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy616; + if (yych == 'o') goto yy617; + goto yy109; +yy616: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy620; + goto yy109; +yy617: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'w') goto yy109; + yyaccept = 44; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy619: +#line 107 "cpp.re" + { BOOST_WAVE_RET(T_THROW); } +#line 4806 "cpp_re.inc" +yy620: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'o') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 45; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy628: +#line 106 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_THREADLOCAL : T_IDENTIFIER); } +#line 4839 "cpp_re.inc" +yy629: + yyaccept = 46; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy630: +#line 105 "cpp.re" + { BOOST_WAVE_RET(T_THIS); } +#line 4851 "cpp_re.inc" +yy631: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 47; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy637: +#line 104 "cpp.re" + { BOOST_WAVE_RET(T_TEMPLATE); } +#line 4878 "cpp_re.inc" +yy638: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy680; + goto yy109; +yy639: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'g') goto yy670; + if (yych == 'z') goto yy671; + goto yy109; +yy640: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy647; + if (yych == 'r') goto yy648; + goto yy109; +yy641: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'h') goto yy109; + yyaccept = 48; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy646: +#line 103 "cpp.re" + { BOOST_WAVE_RET(T_SWITCH); } +#line 4919 "cpp_re.inc" +yy647: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 't') goto yy653; + goto yy109; +yy648: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'u') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 49; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy652: +#line 102 "cpp.re" + { BOOST_WAVE_RET(T_STRUCT); } +#line 4945 "cpp_re.inc" +yy653: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 50; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') { + if (yych <= '/') { + if (yych == '$') goto yy108; + } else { + if (yych <= '9') goto yy108; + if (yych == '?') goto yy111; + } + } else { + if (yych <= '^') { + if (yych <= 'Z') goto yy108; + if (yych == '\\') goto yy110; + } else { + if (yych <= '_') goto yy657; + if (yych <= '`') goto yy656; + if (yych <= 'z') goto yy108; + } + } +yy656: +#line 99 "cpp.re" + { BOOST_WAVE_RET(T_STATIC); } +#line 4975 "cpp_re.inc" +yy657: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy658; + if (yych == 'c') goto yy659; + goto yy109; +yy658: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 's') goto yy664; + goto yy109; +yy659: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 51; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy663: +#line 100 "cpp.re" + { BOOST_WAVE_RET(T_STATICCAST); } +#line 5007 "cpp_re.inc" +yy664: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 52; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy669: +#line 101 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_STATICASSERT : T_IDENTIFIER); } +#line 5031 "cpp_re.inc" +yy670: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy676; + goto yy109; +yy671: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'o') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'f') goto yy109; + yyaccept = 53; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy675: +#line 98 "cpp.re" + { BOOST_WAVE_RET(T_SIZEOF); } +#line 5057 "cpp_re.inc" +yy676: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 54; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy679: +#line 97 "cpp.re" + { BOOST_WAVE_RET(T_SIGNED); } +#line 5075 "cpp_re.inc" +yy680: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 55; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy683: +#line 96 "cpp.re" + { BOOST_WAVE_RET(T_SHORT); } +#line 5093 "cpp_re.inc" +yy684: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'h') { + if (yych != 'g') goto yy109; + } else { + if (yych <= 'i') goto yy686; + if (yych == 't') goto yy687; + goto yy109; + } + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy706; + goto yy109; +yy686: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy692; + goto yy109; +yy687: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'u') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 56; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy691: +#line 95 "cpp.re" + { BOOST_WAVE_RET(T_RETURN); } +#line 5133 "cpp_re.inc" +yy692: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 57; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy705: +#line 94 "cpp.re" + { BOOST_WAVE_RET(T_REINTERPRETCAST); } +#line 5181 "cpp_re.inc" +yy706: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 58; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy711: +#line 93 "cpp.re" + { BOOST_WAVE_RET(T_REGISTER); } +#line 5205 "cpp_re.inc" +yy712: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy719; + if (yych == 'o') goto yy720; + goto yy109; +yy713: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'b') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 59; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy718: +#line 92 "cpp.re" + { BOOST_WAVE_RET(T_PUBLIC); } +#line 5235 "cpp_re.inc" +yy719: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'v') goto yy728; + goto yy109; +yy720: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 60; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy727: +#line 91 "cpp.re" + { BOOST_WAVE_RET(T_PROTECTED); } +#line 5270 "cpp_re.inc" +yy728: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 61; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy732: +#line 90 "cpp.re" + { BOOST_WAVE_RET(T_PRIVATE); } +#line 5291 "cpp_re.inc" +yy733: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy740; + goto yy109; +yy734: + yyaccept = 62; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') { + if (yych <= '/') { + if (yych == '$') goto yy108; + } else { + if (yych <= '9') goto yy108; + if (yych == '?') goto yy111; + } + } else { + if (yych <= '^') { + if (yych <= 'Z') goto yy108; + if (yych == '\\') goto yy110; + } else { + if (yych <= '_') goto yy736; + if (yych <= '`') goto yy735; + if (yych <= 'z') goto yy108; + } + } +yy735: +#line 233 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OROR_ALT); } +#line 5320 "cpp_re.inc" +yy736: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'q') goto yy109; + yyaccept = 63; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy739: +#line 217 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ORASSIGN_ALT); } +#line 5338 "cpp_re.inc" +yy740: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'o') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 64; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy746: +#line 89 "cpp.re" + { BOOST_WAVE_RET(T_OPERATOR); } +#line 5365 "cpp_re.inc" +yy747: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'm') goto yy772; + goto yy109; +yy748: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'w') goto yy770; + goto yy109; +yy749: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy757; + if (yych == 't') goto yy758; + goto yy109; +yy750: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 65; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy756: +#line 88 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NULLPTR : T_IDENTIFIER); } +#line 5408 "cpp_re.inc" +yy757: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'x') goto yy764; + goto yy109; +yy758: + yyaccept = 66; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') { + if (yych <= '/') { + if (yych == '$') goto yy108; + } else { + if (yych <= '9') goto yy108; + if (yych == '?') goto yy111; + } + } else { + if (yych <= '^') { + if (yych <= 'Z') goto yy108; + if (yych == '\\') goto yy110; + } else { + if (yych <= '_') goto yy760; + if (yych <= '`') goto yy759; + if (yych <= 'z') goto yy108; + } + } +yy759: +#line 202 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOT_ALT); } +#line 5437 "cpp_re.inc" +yy760: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'q') goto yy109; + yyaccept = 67; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy763: +#line 225 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_NOTEQUAL_ALT); } +#line 5455 "cpp_re.inc" +yy764: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 68; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy769: +#line 87 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_NOEXCEPT : T_IDENTIFIER); } +#line 5479 "cpp_re.inc" +yy770: + yyaccept = 69; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy771: +#line 86 "cpp.re" + { BOOST_WAVE_RET(T_NEW); } +#line 5491 "cpp_re.inc" +yy772: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 70; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy779: +#line 85 "cpp.re" + { BOOST_WAVE_RET(T_NAMESPACE); } +#line 5521 "cpp_re.inc" +yy780: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'b') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 71; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy786: +#line 84 "cpp.re" + { BOOST_WAVE_RET(T_MUTABLE); } +#line 5548 "cpp_re.inc" +yy787: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'g') goto yy109; + yyaccept = 72; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy790: +#line 83 "cpp.re" + { BOOST_WAVE_RET(T_LONG); } +#line 5566 "cpp_re.inc" +yy791: + yyaccept = 73; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy792: +#line 79 "cpp.re" + { BOOST_WAVE_RET(T_IF); } +#line 5578 "cpp_re.inc" +yy793: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'p') goto yy802; + goto yy109; +yy794: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'l') goto yy795; + if (yych == 't') goto yy796; + goto yy109; +yy795: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy798; + goto yy109; +yy796: + yyaccept = 74; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy797: +#line 82 "cpp.re" + { BOOST_WAVE_RET(T_INT); } +#line 5606 "cpp_re.inc" +yy798: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 75; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy801: +#line 81 "cpp.re" + { BOOST_WAVE_RET(T_INLINE); } +#line 5624 "cpp_re.inc" +yy802: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'o') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 76; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy806: +#line 80 "cpp.re" + { BOOST_WAVE_RET(s->enable_import_keyword ? T_IMPORT : T_IDENTIFIER); } +#line 5645 "cpp_re.inc" +yy807: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'o') goto yy109; + yyaccept = 77; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy810: +#line 78 "cpp.re" + { BOOST_WAVE_RET(T_GOTO); } +#line 5663 "cpp_re.inc" +yy811: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'l') goto yy826; + goto yy109; +yy812: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy822; + goto yy109; +yy813: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'r') goto yy820; + goto yy109; +yy814: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 78; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy819: +#line 77 "cpp.re" + { BOOST_WAVE_RET(T_FRIEND); } +#line 5702 "cpp_re.inc" +yy820: + yyaccept = 79; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy821: +#line 76 "cpp.re" + { BOOST_WAVE_RET(T_FOR); } +#line 5714 "cpp_re.inc" +yy822: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 80; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy825: +#line 75 "cpp.re" + { BOOST_WAVE_RET(T_FLOAT); } +#line 5732 "cpp_re.inc" +yy826: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 81; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy829: +#line 74 "cpp.re" + { BOOST_WAVE_RET(T_FALSE); } +#line 5750 "cpp_re.inc" +yy830: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 's') goto yy852; + goto yy109; +yy831: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'u') goto yy849; + goto yy109; +yy832: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'p') goto yy833; + if (yych == 't') goto yy834; + goto yy109; +yy833: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'l') goto yy839; + if (yych == 'o') goto yy840; + goto yy109; +yy834: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 82; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy838: +#line 73 "cpp.re" + { BOOST_WAVE_RET(T_EXTERN); } +#line 5793 "cpp_re.inc" +yy839: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy844; + goto yy109; +yy840: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 83; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy843: +#line 72 "cpp.re" + { BOOST_WAVE_RET(T_EXPORT); } +#line 5816 "cpp_re.inc" +yy844: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 84; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy848: +#line 71 "cpp.re" + { BOOST_WAVE_RET(T_EXPLICIT); } +#line 5837 "cpp_re.inc" +yy849: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'm') goto yy109; + yyaccept = 85; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy851: +#line 70 "cpp.re" + { BOOST_WAVE_RET(T_ENUM); } +#line 5852 "cpp_re.inc" +yy852: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 86; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy854: +#line 69 "cpp.re" + { BOOST_WAVE_RET(T_ELSE); } +#line 5867 "cpp_re.inc" +yy855: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'e') { + if (yych == 'c') goto yy875; + goto yy109; + } else { + if (yych <= 'f') goto yy876; + if (yych == 'l') goto yy877; + goto yy109; + } +yy856: + yyaccept = 87; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'Z') { + if (yych <= '9') { + if (yych == '$') goto yy108; + if (yych >= '0') goto yy108; + } else { + if (yych == '?') goto yy111; + if (yych >= 'A') goto yy108; + } + } else { + if (yych <= '_') { + if (yych == '\\') goto yy110; + if (yych >= '_') goto yy108; + } else { + if (yych <= 't') { + if (yych >= 'a') goto yy108; + } else { + if (yych <= 'u') goto yy870; + if (yych <= 'z') goto yy108; + } + } + } +yy857: +#line 66 "cpp.re" + { BOOST_WAVE_RET(T_DO); } +#line 5906 "cpp_re.inc" +yy858: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'm') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 88; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy869: +#line 68 "cpp.re" + { BOOST_WAVE_RET(T_DYNAMICCAST); } +#line 5948 "cpp_re.inc" +yy870: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'b') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 89; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy874: +#line 67 "cpp.re" + { BOOST_WAVE_RET(T_DOUBLE); } +#line 5969 "cpp_re.inc" +yy875: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'l') goto yy887; + goto yy109; +yy876: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy882; + goto yy109; +yy877: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 90; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy881: +#line 65 "cpp.re" + { BOOST_WAVE_RET(T_DELETE); } +#line 6000 "cpp_re.inc" +yy882: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'u') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 91; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy886: +#line 64 "cpp.re" + { BOOST_WAVE_RET(T_DEFAULT); } +#line 6021 "cpp_re.inc" +yy887: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'y') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 92; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy892: +#line 63 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_DECLTYPE : T_IDENTIFIER); } +#line 6045 "cpp_re.inc" +yy893: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'r') goto yy109; + if (yych <= 's') goto yy939; + if (yych <= 't') goto yy940; + goto yy109; +yy894: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy926; + goto yy109; +yy895: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy922; + goto yy109; +yy896: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'l') goto yy109; + if (yych <= 'm') goto yy898; + if (yych >= 'o') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'r') goto yy109; + if (yych <= 's') goto yy902; + if (yych <= 't') goto yy903; + goto yy109; +yy898: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 93; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy901: +#line 200 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_COMPL_ALT); } +#line 6092 "cpp_re.inc" +yy902: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 't') goto yy909; + goto yy109; +yy903: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'i') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'u') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 94; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy908: +#line 62 "cpp.re" + { BOOST_WAVE_RET(T_CONTINUE); } +#line 6121 "cpp_re.inc" +yy909: + yyaccept = 95; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= 'Z') { + if (yych <= '9') { + if (yych == '$') goto yy108; + if (yych >= '0') goto yy108; + } else { + if (yych == '?') goto yy111; + if (yych >= 'A') goto yy108; + } + } else { + if (yych <= '_') { + if (yych == '\\') goto yy110; + if (yych >= '_') goto yy911; + } else { + if (yych <= 'd') { + if (yych >= 'a') goto yy108; + } else { + if (yych <= 'e') goto yy912; + if (yych <= 'z') goto yy108; + } + } + } +yy910: +#line 59 "cpp.re" + { BOOST_WAVE_RET(T_CONST); } +#line 6149 "cpp_re.inc" +yy911: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'c') goto yy917; + goto yy109; +yy912: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'x') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'p') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 96; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy916: +#line 60 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CONSTEXPR : T_IDENTIFIER); } +#line 6175 "cpp_re.inc" +yy917: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 97; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy921: +#line 61 "cpp.re" + { BOOST_WAVE_RET(T_CONSTCAST); } +#line 6196 "cpp_re.inc" +yy922: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 's') goto yy109; + yyaccept = 98; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy925: +#line 58 "cpp.re" + { BOOST_WAVE_RET(T_CLASS); } +#line 6214 "cpp_re.inc" +yy926: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 99; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '>') { + if (yych <= '0') { + if (yych == '$') goto yy108; + if (yych >= '0') goto yy108; + } else { + if (yych <= '2') { + if (yych <= '1') goto yy929; + goto yy108; + } else { + if (yych <= '3') goto yy930; + if (yych <= '9') goto yy108; + } + } + } else { + if (yych <= '\\') { + if (yych <= '@') { + if (yych <= '?') goto yy111; + } else { + if (yych <= 'Z') goto yy108; + if (yych >= '\\') goto yy110; + } + } else { + if (yych <= '_') { + if (yych >= '_') goto yy108; + } else { + if (yych <= '`') goto yy928; + if (yych <= 'z') goto yy108; + } + } + } +yy928: +#line 55 "cpp.re" + { BOOST_WAVE_RET(T_CHAR); } +#line 6254 "cpp_re.inc" +yy929: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '6') goto yy935; + goto yy109; +yy930: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '2') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 100; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy934: +#line 57 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR32_T : T_IDENTIFIER); } +#line 6280 "cpp_re.inc" +yy935: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != '_') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 101; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy938: +#line 56 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_CHAR16_T : T_IDENTIFIER); } +#line 6298 "cpp_re.inc" +yy939: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'e') goto yy944; + goto yy109; +yy940: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'c') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'h') goto yy109; + yyaccept = 102; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy943: +#line 54 "cpp.re" + { BOOST_WAVE_RET(T_CATCH); } +#line 6321 "cpp_re.inc" +yy944: + yyaccept = 103; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy945: +#line 53 "cpp.re" + { BOOST_WAVE_RET(T_CASE); } +#line 6333 "cpp_re.inc" +yy946: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 't') goto yy956; + goto yy109; +yy947: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'o') goto yy953; + goto yy109; +yy948: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'a') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'k') goto yy109; + yyaccept = 104; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy952: +#line 52 "cpp.re" + { BOOST_WAVE_RET(T_BREAK); } +#line 6364 "cpp_re.inc" +yy953: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'l') goto yy109; + yyaccept = 105; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy955: +#line 51 "cpp.re" + { BOOST_WAVE_RET(T_BOOL); } +#line 6379 "cpp_re.inc" +yy956: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy957; + if (yych == 'o') goto yy958; + goto yy109; +yy957: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'n') goto yy961; + goto yy109; +yy958: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'r') goto yy109; + yyaccept = 106; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy960: +#line 196 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_OR_ALT); } +#line 6405 "cpp_re.inc" +yy961: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'd') goto yy109; + yyaccept = 107; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy963: +#line 194 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_AND_ALT); } +#line 6420 "cpp_re.inc" +yy964: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'i') goto yy979; + goto yy109; +yy965: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'd') goto yy973; + goto yy109; +yy966: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'm') goto yy971; + goto yy109; +yy967: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 't') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'o') goto yy109; + yyaccept = 108; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy970: +#line 50 "cpp.re" + { BOOST_WAVE_RET(T_AUTO); } +#line 6453 "cpp_re.inc" +yy971: + yyaccept = 109; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy972: +#line 49 "cpp.re" + { BOOST_WAVE_RET(T_ASM); } +#line 6465 "cpp_re.inc" +yy973: + yyaccept = 110; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '@') { + if (yych <= '/') { + if (yych == '$') goto yy108; + } else { + if (yych <= '9') goto yy108; + if (yych == '?') goto yy111; + } + } else { + if (yych <= '^') { + if (yych <= 'Z') goto yy108; + if (yych == '\\') goto yy110; + } else { + if (yych <= '_') goto yy975; + if (yych <= '`') goto yy974; + if (yych <= 'z') goto yy108; + } + } +yy974: +#line 229 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDAND_ALT); } +#line 6489 "cpp_re.inc" +yy975: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'e') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'q') goto yy109; + yyaccept = 111; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy978: +#line 215 "cpp.re" + { BOOST_WAVE_RET(s->act_in_c99_mode ? T_IDENTIFIER : T_ANDASSIGN_ALT); } +#line 6507 "cpp_re.inc" +yy979: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'g') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'n') goto yy109; + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 'a') goto yy982; + if (yych == 'o') goto yy983; + goto yy109; +yy982: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych == 's') goto yy986; + goto yy109; +yy983: + yyaccept = 1; + yych = *(YYMARKER = ++YYCURSOR); + if (yych != 'f') goto yy109; + yyaccept = 112; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy985: +#line 48 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNOF : T_IDENTIFIER); } +#line 6539 "cpp_re.inc" +yy986: + yyaccept = 113; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[256+yych] & 32) { + goto yy108; + } + if (yych == '?') goto yy111; + if (yych == '\\') goto yy110; +yy987: +#line 47 "cpp.re" + { BOOST_WAVE_RET(s->act_in_cpp0x_mode ? T_ALIGNAS : T_IDENTIFIER); } +#line 6551 "cpp_re.inc" +yy988: + ++YYCURSOR; +#line 176 "cpp.re" + { + if (s->act_in_c99_mode) { + --YYCURSOR; + BOOST_WAVE_RET(T_DOT); + } + else { + BOOST_WAVE_RET(T_DOTSTAR); + } + } +#line 6564 "cpp_re.inc" +yy990: + yych = *++YYCURSOR; + if (yych == '.') goto yy992; + goto yy99; +yy991: + yych = *++YYCURSOR; + goto yy7; +yy992: + ++YYCURSOR; +#line 162 "cpp.re" + { BOOST_WAVE_RET(T_ELLIPSIS); } +#line 6576 "cpp_re.inc" +yy994: + ++YYCURSOR; +#line 209 "cpp.re" + { BOOST_WAVE_RET(T_DIVIDEASSIGN); } +#line 6581 "cpp_re.inc" +yy996: + ++YYCURSOR; +#line 44 "cpp.re" + { goto cppcomment; } +#line 6586 "cpp_re.inc" +yy998: + ++YYCURSOR; +#line 43 "cpp.re" + { goto ccomment; } +#line 6591 "cpp_re.inc" +} +#line 348 "cpp.re" + + +ccomment: + +#line 6598 "cpp_re.inc" +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '\f') { + if (yych <= 0x08) { + if (yych <= 0x00) goto yy1009; + goto yy1011; + } else { + if (yych == '\n') goto yy1004; + goto yy1007; + } + } else { + if (yych <= 0x1F) { + if (yych <= '\r') goto yy1006; + goto yy1011; + } else { + if (yych != '*') goto yy1008; + } + } + ++YYCURSOR; + if ((yych = *YYCURSOR) == '/') goto yy1014; +yy1003: +#line 363 "cpp.re" + { goto ccomment; } +#line 6624 "cpp_re.inc" +yy1004: + ++YYCURSOR; +yy1005: +#line 355 "cpp.re" + { + /*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF);*/ + /*s->tok = cursor; */ + s->line += count_backslash_newlines(s, cursor) +1; + cursor.column = 1; + goto ccomment; + } +#line 6636 "cpp_re.inc" +yy1006: + yych = *++YYCURSOR; + if (yych == '\n') goto yy1013; + goto yy1005; +yy1007: + yych = *++YYCURSOR; + goto yy1003; +yy1008: + yych = *++YYCURSOR; + goto yy1003; +yy1009: + ++YYCURSOR; +#line 366 "cpp.re" + { + if(cursor == s->eof) + { + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_warning, + "Unterminated 'C' style comment"); + } + else + { + --YYCURSOR; // next call returns T_EOF + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_error, + "invalid character: '\\000' in input stream"); + } + } +#line 6665 "cpp_re.inc" +yy1011: + ++YYCURSOR; +#line 383 "cpp.re" + { + // flag the error + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_error, + "invalid character '\\%03o' in input stream", *--YYCURSOR); + } +#line 6675 "cpp_re.inc" +yy1013: + yych = *++YYCURSOR; + goto yy1005; +yy1014: + ++YYCURSOR; +#line 352 "cpp.re" + { BOOST_WAVE_RET(T_CCOMMENT); } +#line 6683 "cpp_re.inc" +} +#line 389 "cpp.re" + + +cppcomment: + +#line 6690 "cpp_re.inc" +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= '\n') { + if (yych <= 0x00) goto yy1024; + if (yych <= 0x08) goto yy1026; + if (yych <= '\t') goto yy1021; + } else { + if (yych <= '\f') goto yy1021; + if (yych <= '\r') goto yy1020; + if (yych <= 0x1F) goto yy1026; + goto yy1023; + } + ++YYCURSOR; +yy1019: +#line 394 "cpp.re" + { + /*if(cursor == s->eof) BOOST_WAVE_RET(T_EOF); */ + /*s->tok = cursor; */ + s->line++; + cursor.column = 1; + BOOST_WAVE_RET(T_CPPCOMMENT); + } +#line 6715 "cpp_re.inc" +yy1020: + yych = *++YYCURSOR; + if (yych == '\n') goto yy1028; + goto yy1019; +yy1021: + ++YYCURSOR; +yy1022: +#line 402 "cpp.re" + { goto cppcomment; } +#line 6725 "cpp_re.inc" +yy1023: + yych = *++YYCURSOR; + goto yy1022; +yy1024: + ++YYCURSOR; +#line 405 "cpp.re" + { + if (s->eof && cursor != s->eof) + { + --YYCURSOR; // next call returns T_EOF + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_error, + "invalid character '\\000' in input stream"); + } + + --YYCURSOR; // next call returns T_EOF + if (!s->single_line_only) + { + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_warning, + "Unterminated 'C++' style comment"); + } + BOOST_WAVE_RET(T_CPPCOMMENT); + } +#line 6750 "cpp_re.inc" +yy1026: + ++YYCURSOR; +#line 425 "cpp.re" + { + // flag the error + BOOST_WAVE_UPDATE_CURSOR(); // adjust the input cursor + (*s->error_proc)(s, lexing_exception::generic_lexing_error, + "invalid character '\\%03o' in input stream", *--YYCURSOR); + } +#line 6760 "cpp_re.inc" +yy1028: + ++YYCURSOR; + yych = *YYCURSOR; + goto yy1019; +} +#line 431 "cpp.re" + + +/* this subscanner is called whenever a pp_number has been started */ +pp_number: +{ + cursor = uchar_wrapper(s->tok = s->cur, s->column = s->curr_column); + marker = uchar_wrapper(s->ptr); + limit = uchar_wrapper(s->lim); + + if (s->detect_pp_numbers) { + +#line 6778 "cpp_re.inc" +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 64, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 64, 0, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 0, 0, 0, 0, 0, 0, + 0, 64, 64, 64, 64, 128, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 0, 0, 0, 0, 64, + 0, 64, 64, 64, 64, 128, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych == '.') goto yy1032; + if (yych <= '/') goto yy1031; + if (yych <= '9') goto yy1033; +yy1031: + YYCURSOR = YYMARKER; + goto yy1035; +yy1032: + yych = *++YYCURSOR; + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; +yy1033: + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy1033; + } + if (yych <= 'Z') { + if (yych == '?') goto yy1039; + if (yych >= 'A') goto yy1036; + } else { + if (yych <= '\\') { + if (yych >= '\\') goto yy1038; + } else { + if (yych == 'e') goto yy1036; + } + } +yy1035: +#line 443 "cpp.re" + { BOOST_WAVE_RET(T_PP_NUMBER); } +#line 6847 "cpp_re.inc" +yy1036: + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1036; + } + if (yych <= '>') { + if (yych <= '+') { + if (yych == '$') goto yy1033; + if (yych <= '*') goto yy1035; + goto yy1033; + } else { + if (yych <= '.') { + if (yych <= ',') goto yy1035; + goto yy1033; + } else { + if (yych <= '/') goto yy1035; + if (yych <= '9') goto yy1033; + goto yy1035; + } + } + } else { + if (yych <= '\\') { + if (yych <= '@') { + if (yych <= '?') goto yy1039; + goto yy1035; + } else { + if (yych <= 'Z') goto yy1033; + if (yych <= '[') goto yy1035; + } + } else { + if (yych <= '_') { + if (yych <= '^') goto yy1035; + goto yy1033; + } else { + if (yych <= '`') goto yy1035; + if (yych <= 'z') goto yy1033; + goto yy1035; + } + } + } +yy1038: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == 'U') goto yy1042; + if (yych == 'u') goto yy1041; + goto yy1031; +yy1039: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych != '?') goto yy1031; + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych == '/') goto yy1038; + goto yy1031; +yy1041: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych <= '9') goto yy1050; + goto yy1031; + } else { + if (yych <= 'F') goto yy1050; + if (yych <= '`') goto yy1031; + if (yych <= 'f') goto yy1050; + goto yy1031; + } +yy1042: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1043; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1043: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1044; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1044: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1045; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1045: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1046; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1046: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1047; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1047: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1048; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1048: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1049; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1049: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych <= '9') goto yy1033; + goto yy1031; + } else { + if (yych <= 'F') goto yy1033; + if (yych <= '`') goto yy1031; + if (yych <= 'f') goto yy1033; + goto yy1031; + } +yy1050: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1051; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1051: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych >= ':') goto yy1031; + } else { + if (yych <= 'F') goto yy1052; + if (yych <= '`') goto yy1031; + if (yych >= 'g') goto yy1031; + } +yy1052: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1031; + if (yych <= '9') goto yy1033; + goto yy1031; + } else { + if (yych <= 'F') goto yy1033; + if (yych <= '`') goto yy1031; + if (yych <= 'f') goto yy1033; + goto yy1031; + } +} +#line 444 "cpp.re" + + } + else { + +#line 7063 "cpp_re.inc" +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 224, 224, 224, 224, 224, 224, 224, 224, + 160, 160, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 128, 128, 128, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 128, 128, 128, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + if ((YYLIMIT - YYCURSOR) < 4) YYFILL(4); + yych = *YYCURSOR; + if (yych <= '/') { + if (yych == '.') goto yy1060; + } else { + if (yych <= '0') goto yy1056; + if (yych <= '9') goto yy1058; + } +yy1055: + YYCURSOR = YYMARKER; + if (yyaccept <= 0) { + goto yy1057; + } else { + goto yy1063; + } +yy1056: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 64) { + goto yy1075; + } + if (yych <= 'E') { + if (yych <= '/') { + if (yych == '.') goto yy1061; + } else { + if (yych <= '9') goto yy1078; + if (yych >= 'E') goto yy1071; + } + } else { + if (yych <= 'd') { + if (yych == 'X') goto yy1077; + } else { + if (yych <= 'e') goto yy1071; + if (yych == 'x') goto yy1077; + } + } +yy1057: +#line 451 "cpp.re" + { goto integer_suffix; } +#line 7140 "cpp_re.inc" +yy1058: + yyaccept = 0; + YYMARKER = ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy1058; + } + if (yych <= 'D') { + if (yych == '.') goto yy1061; + goto yy1057; + } else { + if (yych <= 'E') goto yy1071; + if (yych == 'e') goto yy1071; + goto yy1057; + } +yy1060: + yych = *++YYCURSOR; + if (yych <= '/') goto yy1055; + if (yych >= ':') goto yy1055; +yy1061: + yyaccept = 1; + YYMARKER = ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yych <= 'K') { + if (yych <= 'D') { + if (yych <= '/') goto yy1063; + if (yych <= '9') goto yy1061; + } else { + if (yych <= 'E') goto yy1064; + if (yych <= 'F') goto yy1065; + } + } else { + if (yych <= 'e') { + if (yych <= 'L') goto yy1066; + if (yych >= 'e') goto yy1064; + } else { + if (yych <= 'f') goto yy1065; + if (yych == 'l') goto yy1066; + } + } +yy1063: +#line 449 "cpp.re" + { BOOST_WAVE_RET(T_FLOATLIT); } +#line 7186 "cpp_re.inc" +yy1064: + yych = *++YYCURSOR; + if (yych <= ',') { + if (yych == '+') goto yy1068; + goto yy1055; + } else { + if (yych <= '-') goto yy1068; + if (yych <= '/') goto yy1055; + if (yych <= '9') goto yy1069; + goto yy1055; + } +yy1065: + yych = *++YYCURSOR; + if (yych == 'L') goto yy1067; + if (yych == 'l') goto yy1067; + goto yy1063; +yy1066: + yych = *++YYCURSOR; + if (yych == 'F') goto yy1067; + if (yych != 'f') goto yy1063; +yy1067: + yych = *++YYCURSOR; + goto yy1063; +yy1068: + yych = *++YYCURSOR; + if (yych <= '/') goto yy1055; + if (yych >= ':') goto yy1055; +yy1069: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 'K') { + if (yych <= '9') { + if (yych <= '/') goto yy1063; + goto yy1069; + } else { + if (yych == 'F') goto yy1065; + goto yy1063; + } + } else { + if (yych <= 'f') { + if (yych <= 'L') goto yy1066; + if (yych <= 'e') goto yy1063; + goto yy1065; + } else { + if (yych == 'l') goto yy1066; + goto yy1063; + } + } +yy1071: + yych = *++YYCURSOR; + if (yych <= ',') { + if (yych != '+') goto yy1055; + } else { + if (yych <= '-') goto yy1072; + if (yych <= '/') goto yy1055; + if (yych <= '9') goto yy1073; + goto yy1055; + } +yy1072: + yych = *++YYCURSOR; + if (yych <= '/') goto yy1055; + if (yych >= ':') goto yy1055; +yy1073: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 'K') { + if (yych <= '9') { + if (yych <= '/') goto yy1063; + goto yy1073; + } else { + if (yych == 'F') goto yy1065; + goto yy1063; + } + } else { + if (yych <= 'f') { + if (yych <= 'L') goto yy1066; + if (yych <= 'e') goto yy1063; + goto yy1065; + } else { + if (yych == 'l') goto yy1066; + goto yy1063; + } + } +yy1075: + yyaccept = 0; + YYMARKER = ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy1075; + } + if (yych <= '9') { + if (yych == '.') goto yy1061; + if (yych <= '/') goto yy1057; + goto yy1078; + } else { + if (yych <= 'E') { + if (yych <= 'D') goto yy1057; + goto yy1071; + } else { + if (yych == 'e') goto yy1071; + goto yy1057; + } + } +yy1077: + yych = *++YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1080; + } + goto yy1055; +yy1078: + ++YYCURSOR; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych == '.') goto yy1061; + if (yych <= '/') goto yy1055; + goto yy1078; + } else { + if (yych <= 'E') { + if (yych <= 'D') goto yy1055; + goto yy1071; + } else { + if (yych == 'e') goto yy1071; + goto yy1055; + } + } +yy1080: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1080; + } + goto yy1057; +} +#line 452 "cpp.re" + + } +} + +/* this subscanner is called, whenever an Integer was recognized */ +integer_suffix: +{ + if (s->enable_ms_extensions) { + +#line 7335 "cpp_re.inc" +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *(YYMARKER = YYCURSOR); + if (yych <= 'h') { + if (yych <= 'L') { + if (yych >= 'L') goto yy1086; + } else { + if (yych == 'U') goto yy1085; + } + } else { + if (yych <= 'l') { + if (yych <= 'i') goto yy1087; + if (yych >= 'l') goto yy1086; + } else { + if (yych == 'u') goto yy1085; + } + } +yy1084: +#line 465 "cpp.re" + { BOOST_WAVE_RET(T_INTLIT); } +#line 7357 "cpp_re.inc" +yy1085: + yych = *++YYCURSOR; + if (yych == 'L') goto yy1094; + if (yych == 'l') goto yy1094; + goto yy1084; +yy1086: + yych = *++YYCURSOR; + if (yych <= 'U') { + if (yych == 'L') goto yy1093; + if (yych <= 'T') goto yy1084; + goto yy1092; + } else { + if (yych <= 'l') { + if (yych <= 'k') goto yy1084; + goto yy1093; + } else { + if (yych == 'u') goto yy1092; + goto yy1084; + } + } +yy1087: + yych = *++YYCURSOR; + if (yych == '6') goto yy1089; +yy1088: + YYCURSOR = YYMARKER; + goto yy1084; +yy1089: + yych = *++YYCURSOR; + if (yych != '4') goto yy1088; +yy1090: + ++YYCURSOR; +yy1091: +#line 462 "cpp.re" + { BOOST_WAVE_RET(T_LONGINTLIT); } +#line 7392 "cpp_re.inc" +yy1092: + yych = *++YYCURSOR; + goto yy1084; +yy1093: + yych = *++YYCURSOR; + if (yych == 'U') goto yy1090; + if (yych == 'u') goto yy1090; + goto yy1091; +yy1094: + ++YYCURSOR; + if ((yych = *YYCURSOR) == 'L') goto yy1090; + if (yych == 'l') goto yy1090; + goto yy1084; +} +#line 466 "cpp.re" + + } + else { + +#line 7412 "cpp_re.inc" +{ + YYCTYPE yych; + if ((YYLIMIT - YYCURSOR) < 3) YYFILL(3); + yych = *YYCURSOR; + if (yych <= 'U') { + if (yych == 'L') goto yy1099; + if (yych >= 'U') goto yy1098; + } else { + if (yych <= 'l') { + if (yych >= 'l') goto yy1099; + } else { + if (yych == 'u') goto yy1098; + } + } +yy1097: +#line 474 "cpp.re" + { BOOST_WAVE_RET(T_INTLIT); } +#line 7430 "cpp_re.inc" +yy1098: + yych = *++YYCURSOR; + if (yych == 'L') goto yy1104; + if (yych == 'l') goto yy1104; + goto yy1097; +yy1099: + yych = *++YYCURSOR; + if (yych <= 'U') { + if (yych == 'L') goto yy1101; + if (yych <= 'T') goto yy1097; + } else { + if (yych <= 'l') { + if (yych <= 'k') goto yy1097; + goto yy1101; + } else { + if (yych != 'u') goto yy1097; + } + } + yych = *++YYCURSOR; + goto yy1097; +yy1101: + ++YYCURSOR; + if ((yych = *YYCURSOR) == 'U') goto yy1103; + if (yych == 'u') goto yy1103; +yy1102: +#line 471 "cpp.re" + { BOOST_WAVE_RET(T_LONGINTLIT); } +#line 7458 "cpp_re.inc" +yy1103: + yych = *++YYCURSOR; + goto yy1102; +yy1104: + ++YYCURSOR; + if ((yych = *YYCURSOR) == 'L') goto yy1103; + if (yych == 'l') goto yy1103; + goto yy1097; +} +#line 475 "cpp.re" + + } +} + +/* this subscanner is invoked for C++0x extended character literals */ +extcharlit: +{ + +#line 7477 "cpp_re.inc" +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 128, 128, 128, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 128, 128, 128, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + if ((YYLIMIT - YYCURSOR) < 13) YYFILL(13); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x08) goto yy1107; + if (yych <= '\t') goto yy1108; + goto yy1112; + } else { + if (yych <= '\f') goto yy1108; + if (yych <= '\r') goto yy1112; + } + } else { + if (yych <= '>') { + if (yych == '\'') goto yy1112; + goto yy1108; + } else { + if (yych <= '?') goto yy1110; + if (yych == '\\') goto yy1111; + goto yy1108; + } + } +yy1107: + YYCURSOR = YYMARKER; + goto yy1109; +yy1108: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '\'') goto yy1120; +yy1109: +#line 487 "cpp.re" + { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); } +#line 7544 "cpp_re.inc" +yy1110: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '\'') goto yy1120; + if (yych == '?') goto yy1135; + goto yy1109; +yy1111: + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy1115; + goto yy1109; + } else { + if (yych <= '\'') goto yy1115; + if (yych <= '/') goto yy1109; + goto yy1118; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy1116; + goto yy1109; + } else { + if (yych <= 'U') goto yy1114; + if (yych == '\\') goto yy1115; + goto yy1109; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy1115; + if (yych <= 'e') goto yy1109; + goto yy1115; + } else { + if (yych == 'n') goto yy1115; + if (yych <= 'q') goto yy1109; + goto yy1115; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy1109; + if (yych <= 't') goto yy1115; + goto yy1113; + } else { + if (yych <= 'v') goto yy1115; + if (yych == 'x') goto yy1117; + goto yy1109; + } + } + } +yy1112: + yych = *++YYCURSOR; + goto yy1109; +yy1113: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych <= '9') goto yy1132; + goto yy1107; + } else { + if (yych <= 'F') goto yy1132; + if (yych <= '`') goto yy1107; + if (yych <= 'f') goto yy1132; + goto yy1107; + } +yy1114: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych <= '9') goto yy1125; + goto yy1107; + } else { + if (yych <= 'F') goto yy1125; + if (yych <= '`') goto yy1107; + if (yych <= 'f') goto yy1125; + goto yy1107; + } +yy1115: + yych = *++YYCURSOR; + if (yych == '\'') goto yy1120; + goto yy1107; +yy1116: + yych = *++YYCURSOR; + if (yych == '\'') goto yy1120; + if (yych == '?') goto yy1124; + goto yy1107; +yy1117: + yych = *++YYCURSOR; + if (yych == '\'') goto yy1107; + goto yy1123; +yy1118: + yych = *++YYCURSOR; + if (yych == '\'') goto yy1120; + if (yych <= '/') goto yy1107; + if (yych >= '8') goto yy1107; + yych = *++YYCURSOR; + if (yych == '\'') goto yy1120; + if (yych <= '/') goto yy1107; + if (yych <= '7') goto yy1115; + goto yy1107; +yy1120: + ++YYCURSOR; +#line 484 "cpp.re" + { BOOST_WAVE_RET(T_CHARLIT); } +#line 7649 "cpp_re.inc" +yy1122: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy1123: + if (yybm[0+yych] & 128) { + goto yy1122; + } + if (yych == '\'') goto yy1120; + goto yy1107; +yy1124: + yych = *++YYCURSOR; + if (yych == '/') goto yy1115; + goto yy1107; +yy1125: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1126; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1126: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1127; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1127: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1128; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1128: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1129; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1129: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1130; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1130: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1131; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1131: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych <= '9') goto yy1115; + goto yy1107; + } else { + if (yych <= 'F') goto yy1115; + if (yych <= '`') goto yy1107; + if (yych <= 'f') goto yy1115; + goto yy1107; + } +yy1132: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1133; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1133: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych >= ':') goto yy1107; + } else { + if (yych <= 'F') goto yy1134; + if (yych <= '`') goto yy1107; + if (yych >= 'g') goto yy1107; + } +yy1134: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1107; + if (yych <= '9') goto yy1115; + goto yy1107; + } else { + if (yych <= 'F') goto yy1115; + if (yych <= '`') goto yy1107; + if (yych <= 'f') goto yy1115; + goto yy1107; + } +yy1135: + yych = *++YYCURSOR; + if (yych != '/') goto yy1107; + ++YYCURSOR; + if ((yych = *YYCURSOR) <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy1115; + goto yy1107; + } else { + if (yych <= '\'') goto yy1115; + if (yych <= '/') goto yy1107; + goto yy1118; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy1116; + goto yy1107; + } else { + if (yych <= 'U') goto yy1114; + if (yych == '\\') goto yy1115; + goto yy1107; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy1115; + if (yych <= 'e') goto yy1107; + goto yy1115; + } else { + if (yych == 'n') goto yy1115; + if (yych <= 'q') goto yy1107; + goto yy1115; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy1107; + if (yych <= 't') goto yy1115; + goto yy1113; + } else { + if (yych <= 'v') goto yy1115; + if (yych == 'x') goto yy1117; + goto yy1107; + } + } + } +} +#line 488 "cpp.re" + +} + +/* this subscanner is invoked for C++0x extended character string literals */ +extstringlit: +{ + +#line 7824 "cpp_re.inc" +{ + YYCTYPE yych; + unsigned int yyaccept = 0; + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 16, 0, 16, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 16, 16, 0, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 144, 144, 144, 144, 144, 144, 144, 144, + 144, 144, 16, 16, 16, 16, 16, 32, + 16, 144, 144, 144, 144, 144, 144, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 64, 16, 16, 16, + 16, 144, 144, 144, 144, 144, 144, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, + }; + if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x08) goto yy1139; + if (yych <= '\t') goto yy1140; + goto yy1146; + } else { + if (yych <= '\f') goto yy1140; + if (yych <= '\r') goto yy1146; + } + } else { + if (yych <= '>') { + if (yych == '"') goto yy1144; + goto yy1140; + } else { + if (yych <= '?') goto yy1142; + if (yych == '\\') goto yy1143; + goto yy1140; + } + } +yy1139: + YYCURSOR = YYMARKER; + if (yyaccept <= 0) { + goto yy1141; + } else { + goto yy1145; + } +yy1140: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '\n') { + if (yych == '\t') goto yy1150; + } else { + if (yych <= '\f') goto yy1150; + if (yych >= ' ') goto yy1150; + } +yy1141: +#line 499 "cpp.re" + { BOOST_WAVE_RET(TOKEN_FROM_ID(*s->tok, UnknownTokenType)); } +#line 7902 "cpp_re.inc" +yy1142: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yybm[0+yych] & 32) { + goto yy1158; + } + if (yych <= '\n') { + if (yych == '\t') goto yy1150; + goto yy1141; + } else { + if (yych <= '\f') goto yy1150; + if (yych <= 0x1F) goto yy1141; + goto yy1150; + } +yy1143: + yyaccept = 0; + yych = *(YYMARKER = ++YYCURSOR); + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy1149; + goto yy1141; + } else { + if (yych <= '\'') goto yy1149; + if (yych <= '/') goto yy1141; + goto yy1153; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy1151; + goto yy1141; + } else { + if (yych <= 'U') goto yy1148; + if (yych == '\\') goto yy1149; + goto yy1141; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy1149; + if (yych <= 'e') goto yy1141; + goto yy1149; + } else { + if (yych == 'n') goto yy1149; + if (yych <= 'q') goto yy1141; + goto yy1149; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy1141; + if (yych <= 't') goto yy1149; + goto yy1147; + } else { + if (yych <= 'v') goto yy1149; + if (yych == 'x') goto yy1152; + goto yy1141; + } + } + } +yy1144: + ++YYCURSOR; +yy1145: +#line 496 "cpp.re" + { BOOST_WAVE_RET(T_STRINGLIT); } +#line 7968 "cpp_re.inc" +yy1146: + yych = *++YYCURSOR; + goto yy1141; +yy1147: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych <= '9') goto yy1187; + goto yy1139; + } else { + if (yych <= 'F') goto yy1187; + if (yych <= '`') goto yy1139; + if (yych <= 'f') goto yy1187; + goto yy1139; + } +yy1148: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych <= '9') goto yy1180; + goto yy1139; + } else { + if (yych <= 'F') goto yy1180; + if (yych <= '`') goto yy1139; + if (yych <= 'f') goto yy1180; + goto yy1139; + } +yy1149: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; +yy1150: + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1156; + goto yy1157; +yy1151: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1179; + goto yy1157; +yy1152: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1166; + } + goto yy1139; +yy1153: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '"') { + if (yych <= '\n') { + if (yych == '\t') goto yy1149; + goto yy1139; + } else { + if (yych <= '\f') goto yy1149; + if (yych <= 0x1F) goto yy1139; + if (yych <= '!') goto yy1149; + goto yy1155; + } + } else { + if (yych <= '>') { + if (yych <= '/') goto yy1149; + if (yych >= '8') goto yy1149; + } else { + if (yych <= '?') goto yy1156; + if (yych == '\\') goto yy1157; + goto yy1149; + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1156; + goto yy1157; +yy1155: + yych = *++YYCURSOR; + goto yy1145; +yy1156: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1158; +yy1157: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy1149; + goto yy1139; + } else { + if (yych <= '\'') goto yy1149; + if (yych <= '/') goto yy1139; + goto yy1153; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy1151; + goto yy1139; + } else { + if (yych <= 'U') goto yy1148; + if (yych == '\\') goto yy1149; + goto yy1139; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy1149; + if (yych <= 'e') goto yy1139; + goto yy1149; + } else { + if (yych == 'n') goto yy1149; + if (yych <= 'q') goto yy1139; + goto yy1149; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy1139; + if (yych <= 't') goto yy1149; + goto yy1147; + } else { + if (yych <= 'v') goto yy1149; + if (yych == 'x') goto yy1152; + goto yy1139; + } + } + } +yy1158: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy1158; + } + if (yych <= '!') { + if (yych <= '\n') { + if (yych == '\t') goto yy1149; + goto yy1139; + } else { + if (yych <= '\f') goto yy1149; + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } + } else { + if (yych <= '/') { + if (yych <= '"') goto yy1155; + if (yych <= '.') goto yy1149; + } else { + if (yych == '\\') goto yy1157; + goto yy1149; + } + } +yy1160: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 64) { + goto yy1160; + } + if (yych <= '7') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1164; + if (yych <= '/') goto yy1149; + goto yy1153; + } + } + } else { + if (yych <= 'U') { + if (yych == '?') goto yy1165; + if (yych <= 'T') goto yy1149; + goto yy1163; + } else { + if (yych <= 'u') { + if (yych <= 't') goto yy1149; + } else { + if (yych == 'x') goto yy1166; + goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + goto yy1176; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + goto yy1176; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych <= 'f') goto yy1176; + goto yy1149; + } + } + } +yy1163: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + goto yy1169; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + goto yy1169; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych <= 'f') goto yy1169; + goto yy1149; + } + } + } +yy1164: + yyaccept = 1; + YYMARKER = ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1145; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1156; + goto yy1157; +yy1165: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1168; + goto yy1157; +yy1166: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1166; + } + if (yych <= '!') { + if (yych <= '\n') { + if (yych == '\t') goto yy1149; + goto yy1139; + } else { + if (yych <= '\f') goto yy1149; + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } + } else { + if (yych <= '?') { + if (yych <= '"') goto yy1155; + if (yych <= '>') goto yy1149; + goto yy1156; + } else { + if (yych == '\\') goto yy1157; + goto yy1149; + } + } +yy1168: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 32) { + goto yy1158; + } + if (yych <= '!') { + if (yych <= '\n') { + if (yych == '\t') goto yy1149; + goto yy1139; + } else { + if (yych <= '\f') goto yy1149; + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } + } else { + if (yych <= '/') { + if (yych <= '"') goto yy1155; + if (yych <= '.') goto yy1149; + goto yy1160; + } else { + if (yych == '\\') goto yy1157; + goto yy1149; + } + } +yy1169: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1156; + goto yy1157; +yy1176: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '9') { + if (yych <= '\f') { + if (yych == '\t') goto yy1149; + if (yych <= '\n') goto yy1139; + goto yy1149; + } else { + if (yych <= '!') { + if (yych <= 0x1F) goto yy1139; + goto yy1149; + } else { + if (yych <= '"') goto yy1155; + if (yych <= '/') goto yy1149; + } + } + } else { + if (yych <= 'F') { + if (yych == '?') goto yy1156; + if (yych <= '@') goto yy1149; + } else { + if (yych <= '\\') { + if (yych <= '[') goto yy1149; + goto yy1157; + } else { + if (yych <= '`') goto yy1149; + if (yych >= 'g') goto yy1149; + } + } + } + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1156; + goto yy1157; +yy1179: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 16) { + goto yy1149; + } + if (yych <= '!') goto yy1139; + if (yych <= '"') goto yy1155; + if (yych <= '[') goto yy1158; + goto yy1157; +yy1180: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1181; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1181: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1182; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1182: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1183; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1183: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1184; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1184: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1185; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1185: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1186; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1186: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych <= '9') goto yy1149; + goto yy1139; + } else { + if (yych <= 'F') goto yy1149; + if (yych <= '`') goto yy1139; + if (yych <= 'f') goto yy1149; + goto yy1139; + } +yy1187: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1188; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1188: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych >= ':') goto yy1139; + } else { + if (yych <= 'F') goto yy1189; + if (yych <= '`') goto yy1139; + if (yych >= 'g') goto yy1139; + } +yy1189: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1139; + if (yych <= '9') goto yy1149; + goto yy1139; + } else { + if (yych <= 'F') goto yy1149; + if (yych <= '`') goto yy1139; + if (yych <= 'f') goto yy1149; + goto yy1139; + } +} +#line 500 "cpp.re" + +} + +extrawstringlit: +{ + +#line 8743 "cpp_re.inc" +{ + YYCTYPE yych; + static const unsigned char yybm[] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 128, 128, 128, 128, 128, 128, 128, 128, + 128, 128, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 128, 128, 128, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 128, 128, 128, 128, 128, 128, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + }; + if ((YYLIMIT - YYCURSOR) < 12) YYFILL(12); + yych = *YYCURSOR; + if (yych <= 0x1F) { + if (yych <= '\n') { + if (yych <= 0x08) goto yy1192; + if (yych <= '\t') goto yy1193; + goto yy1197; + } else { + if (yych <= '\f') goto yy1193; + if (yych <= '\r') goto yy1199; + } + } else { + if (yych <= '>') { + if (yych == '"') goto yy1200; + goto yy1193; + } else { + if (yych <= '?') goto yy1195; + if (yych == '\\') goto yy1196; + goto yy1193; + } + } +yy1192: + YYCURSOR = YYMARKER; + goto yy1194; +yy1193: + ++YYCURSOR; +yy1194: +#line 507 "cpp.re" + { + goto extrawstringlit; + } +#line 8811 "cpp_re.inc" +yy1195: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '?') goto yy1221; + goto yy1194; +yy1196: + yych = *++YYCURSOR; + if (yych <= '`') { + if (yych <= '7') { + if (yych <= '&') { + if (yych == '"') goto yy1193; + goto yy1192; + } else { + if (yych <= '\'') goto yy1193; + if (yych <= '/') goto yy1192; + goto yy1206; + } + } else { + if (yych <= 'T') { + if (yych == '?') goto yy1204; + goto yy1192; + } else { + if (yych <= 'U') goto yy1203; + if (yych == '\\') goto yy1193; + goto yy1192; + } + } + } else { + if (yych <= 'r') { + if (yych <= 'f') { + if (yych <= 'b') goto yy1193; + if (yych <= 'e') goto yy1192; + goto yy1193; + } else { + if (yych == 'n') goto yy1193; + if (yych <= 'q') goto yy1192; + goto yy1193; + } + } else { + if (yych <= 'u') { + if (yych <= 's') goto yy1192; + if (yych <= 't') goto yy1193; + goto yy1202; + } else { + if (yych <= 'v') goto yy1193; + if (yych == 'x') goto yy1205; + goto yy1192; + } + } + } +yy1197: + ++YYCURSOR; +yy1198: +#line 512 "cpp.re" + { + s->line += count_backslash_newlines(s, cursor) +1; + cursor.column = 1; + goto extrawstringlit; + } +#line 8870 "cpp_re.inc" +yy1199: + yych = *++YYCURSOR; + if (yych == '\n') goto yy1197; + goto yy1198; +yy1200: + ++YYCURSOR; +#line 518 "cpp.re" + { BOOST_WAVE_RET(T_RAWSTRINGLIT); } +#line 8879 "cpp_re.inc" +yy1202: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych <= '9') goto yy1218; + goto yy1192; + } else { + if (yych <= 'F') goto yy1218; + if (yych <= '`') goto yy1192; + if (yych <= 'f') goto yy1218; + goto yy1192; + } +yy1203: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych <= '9') goto yy1211; + goto yy1192; + } else { + if (yych <= 'F') goto yy1211; + if (yych <= '`') goto yy1192; + if (yych <= 'f') goto yy1211; + goto yy1192; + } +yy1204: + yych = *(YYMARKER = ++YYCURSOR); + if (yych == '?') goto yy1210; + goto yy1194; +yy1205: + yych = *++YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1208; + } + goto yy1192; +yy1206: + yych = *++YYCURSOR; + if (yych <= '/') goto yy1194; + if (yych >= '8') goto yy1194; + yych = *++YYCURSOR; + if (yych <= '/') goto yy1194; + if (yych <= '7') goto yy1193; + goto yy1194; +yy1208: + ++YYCURSOR; + if (YYLIMIT <= YYCURSOR) YYFILL(1); + yych = *YYCURSOR; + if (yybm[0+yych] & 128) { + goto yy1208; + } + goto yy1194; +yy1210: + yych = *++YYCURSOR; + if (yych == '/') goto yy1193; + goto yy1192; +yy1211: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1212; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1212: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1213; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1213: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1214; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1214: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1215; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1215: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1216; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1216: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1217; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1217: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych <= '9') goto yy1193; + goto yy1192; + } else { + if (yych <= 'F') goto yy1193; + if (yych <= '`') goto yy1192; + if (yych <= 'f') goto yy1193; + goto yy1192; + } +yy1218: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1219; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1219: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych >= ':') goto yy1192; + } else { + if (yych <= 'F') goto yy1220; + if (yych <= '`') goto yy1192; + if (yych >= 'g') goto yy1192; + } +yy1220: + yych = *++YYCURSOR; + if (yych <= '@') { + if (yych <= '/') goto yy1192; + if (yych <= '9') goto yy1193; + goto yy1192; + } else { + if (yych <= 'F') goto yy1193; + if (yych <= '`') goto yy1192; + if (yych <= 'f') goto yy1193; + goto yy1192; + } +yy1221: + ++YYCURSOR; + if ((yych = *YYCURSOR) == '/') goto yy1196; + goto yy1192; +} +#line 519 "cpp.re" + +} diff --git a/extern/shiny/Preprocessor/instantiate_cpp_exprgrammar.cpp b/extern/shiny/Preprocessor/instantiate_cpp_exprgrammar.cpp new file mode 100644 index 0000000000..7318c29fa4 --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_cpp_exprgrammar.cpp @@ -0,0 +1,52 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> + +#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + +#include <string> +#include <utility> + +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +#include <boost/wave/grammars/cpp_expression_grammar.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Explicit instantiation of the expression_grammar_gen template with the +// correct lexer iterator type. This instantiates the corresponding parse +// function, which in turn instantiates the expression_grammar object (see +// wave/grammars/cpp_expression_grammar.hpp) +// +/////////////////////////////////////////////////////////////////////////////// + +// if you want to use your own token type the following line must be adjusted +typedef boost::wave::cpplexer::lex_token<> token_type; + +// no need to change anything below +template struct boost::wave::grammars::expression_grammar_gen<token_type>; + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + diff --git a/extern/shiny/Preprocessor/instantiate_cpp_grammar.cpp b/extern/shiny/Preprocessor/instantiate_cpp_grammar.cpp new file mode 100644 index 0000000000..89cc3d7f36 --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_cpp_grammar.cpp @@ -0,0 +1,56 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> + +#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + +#include <string> +#include <list> + +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +#include <boost/wave/grammars/cpp_grammar.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Explicit instantiation of the cpp_grammar_gen template with the correct +// token type. This instantiates the corresponding pt_parse function, which +// in turn instantiates the cpp_grammar object +// (see wave/grammars/cpp_grammar.hpp) +// +/////////////////////////////////////////////////////////////////////////////// + +// if you want to use your own token type the following line must be adjusted +typedef boost::wave::cpplexer::lex_token<> token_type; + +// no need to change anything below +typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type; +typedef std::list<token_type, boost::fast_pool_allocator<token_type> > + token_sequence_type; + +template struct boost::wave::grammars::cpp_grammar_gen<lexer_type, token_sequence_type>; + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + diff --git a/extern/shiny/Preprocessor/instantiate_cpp_literalgrs.cpp b/extern/shiny/Preprocessor/instantiate_cpp_literalgrs.cpp new file mode 100644 index 0000000000..4fbfb87f22 --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_cpp_literalgrs.cpp @@ -0,0 +1,56 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> + +#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + +#include <string> + +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +#include <boost/wave/grammars/cpp_literal_grammar_gen.hpp> +#include <boost/wave/grammars/cpp_intlit_grammar.hpp> +#include <boost/wave/grammars/cpp_chlit_grammar.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Explicit instantiation of the intlit_grammar_gen and chlit_grammar_gen +// templates with the correct token type. This instantiates the corresponding +// parse function, which in turn instantiates the corresponding parser object. +// +/////////////////////////////////////////////////////////////////////////////// + +typedef boost::wave::cpplexer::lex_token<> token_type; + +// no need to change anything below +template struct boost::wave::grammars::intlit_grammar_gen<token_type>; +#if BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_AUTOSELECT || \ + BOOST_WAVE_WCHAR_T_SIGNEDNESS == BOOST_WAVE_WCHAR_T_FORCE_SIGNED +template struct boost::wave::grammars::chlit_grammar_gen<int, token_type>; +#endif +template struct boost::wave::grammars::chlit_grammar_gen<unsigned int, token_type>; + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + diff --git a/extern/shiny/Preprocessor/instantiate_defined_grammar.cpp b/extern/shiny/Preprocessor/instantiate_defined_grammar.cpp new file mode 100644 index 0000000000..b7afe3f1ef --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_defined_grammar.cpp @@ -0,0 +1,52 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> + +#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + +#include <string> + +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +#include <boost/wave/grammars/cpp_defined_grammar.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Explicit instantiation of the defined_grammar_gen template +// with the correct token type. This instantiates the corresponding parse +// function, which in turn instantiates the defined_grammar +// object (see wave/grammars/cpp_defined_grammar.hpp) +// +/////////////////////////////////////////////////////////////////////////////// + +// if you want to use your own token type the following line must be adjusted +typedef boost::wave::cpplexer::lex_token<> token_type; + +// no need to change anything below +typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type; +template struct boost::wave::grammars::defined_grammar_gen<lexer_type>; + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + diff --git a/extern/shiny/Preprocessor/instantiate_predef_macros.cpp b/extern/shiny/Preprocessor/instantiate_predef_macros.cpp new file mode 100644 index 0000000000..758ad9734a --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_predef_macros.cpp @@ -0,0 +1,52 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> + +#if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + +#include <string> + +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +#include <boost/wave/grammars/cpp_predef_macros_grammar.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// Explicit instantiation of the predefined_macros_grammar_gen template +// with the correct token type. This instantiates the corresponding pt_parse +// function, which in turn instantiates the cpp_predefined_macros_grammar +// object (see wave/grammars/cpp_predef_macros_grammar.hpp) +// +/////////////////////////////////////////////////////////////////////////////// + +// if you want to use your own token type the following line must be adjusted +typedef boost::wave::cpplexer::lex_token<> token_type; + +// no need to change anything below +typedef boost::wave::cpplexer::lex_iterator<token_type> lexer_type; +template struct boost::wave::grammars::predefined_macros_grammar_gen<lexer_type>; + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // #if BOOST_WAVE_SEPARATE_GRAMMAR_INSTANTIATION != 0 + diff --git a/extern/shiny/Preprocessor/instantiate_re2c_lexer.cpp b/extern/shiny/Preprocessor/instantiate_re2c_lexer.cpp new file mode 100644 index 0000000000..cd1b8898ff --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_re2c_lexer.cpp @@ -0,0 +1,65 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + Explicit instantiation of the lex_functor generation function + + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> // configuration data + +#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0 + +#include <string> + +#include <boost/wave/token_ids.hpp> +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +/////////////////////////////////////////////////////////////////////////////// +// The following file needs to be included only once throughout the whole +// program. +#include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// This instantiates the correct 'new_lexer' function, which generates the +// C++ lexer used in this sample. You will have to instantiate the +// new_lexer_gen<> template with the same iterator type, as you have used for +// instantiating the boost::wave::context<> object. +// +// This is moved into a separate compilation unit to decouple the compilation +// of the C++ lexer from the compilation of the other modules, which helps to +// reduce compilation time. +// +// The template parameter(s) supplied should be identical to the first +// parameter supplied while instantiating the boost::wave::context<> template +// (see the file cpp.cpp). +// +/////////////////////////////////////////////////////////////////////////////// + +// if you want to use another iterator type for the underlying input stream +// a corresponding explicit template instantiation needs to be added below +template struct boost::wave::cpplexer::new_lexer_gen< + BOOST_WAVE_STRINGTYPE::iterator>; +template struct boost::wave::cpplexer::new_lexer_gen< + BOOST_WAVE_STRINGTYPE::const_iterator>; + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0 diff --git a/extern/shiny/Preprocessor/instantiate_re2c_lexer_str.cpp b/extern/shiny/Preprocessor/instantiate_re2c_lexer_str.cpp new file mode 100644 index 0000000000..138ed6c3bb --- /dev/null +++ b/extern/shiny/Preprocessor/instantiate_re2c_lexer_str.cpp @@ -0,0 +1,64 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + Explicit instantiation of the lex_functor generation function + + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> +#include <boost/wave/wave_config.hpp> // configuration data + +#if BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0 + +#include <string> + +#include <boost/wave/token_ids.hpp> +#include <boost/wave/cpplexer/cpp_lex_token.hpp> +#include <boost/wave/cpplexer/cpp_lex_iterator.hpp> + +/////////////////////////////////////////////////////////////////////////////// +// The following file needs to be included only once throughout the whole +// program. +#include <boost/wave/cpplexer/re2clex/cpp_re2c_lexer.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +// +// If you've used another iterator type as std::string::iterator, you have to +// instantiate the new_lexer_gen<> template for this iterator type too. +// The reason is, that the library internally uses the new_lexer_gen<> +// template with a std::string::iterator. (You just have to undefine the +// following line.) +// +// This is moved into a separate compilation unit to decouple the compilation +// of the C++ lexer from the compilation of the other modules, which helps to +// reduce compilation time. +// +// The template parameter(s) supplied should be identical to the first +// parameter supplied while instantiating the boost::wave::context<> template +// (see the file cpp.cpp). +// +/////////////////////////////////////////////////////////////////////////////// + +#if !defined(BOOST_WAVE_STRINGTYPE_USE_STDSTRING) +template struct boost::wave::cpplexer::new_lexer_gen<std::string::iterator>; +template struct boost::wave::cpplexer::new_lexer_gen<std::string::const_iterator>; +#endif + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + +#endif // BOOST_WAVE_SEPARATE_LEXER_INSTANTIATION != 0 diff --git a/extern/shiny/Preprocessor/token_ids.cpp b/extern/shiny/Preprocessor/token_ids.cpp new file mode 100644 index 0000000000..35e7725b43 --- /dev/null +++ b/extern/shiny/Preprocessor/token_ids.cpp @@ -0,0 +1,447 @@ +/*============================================================================= + Boost.Wave: A Standard compliant C++ preprocessor library + The definition of a default set of token identifiers and related + functions. + + http://www.boost.org/ + + Copyright (c) 2001-2011 Hartmut Kaiser. Distributed under the Boost + Software License, Version 1.0. (See accompanying file + LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +=============================================================================*/ + +#define BOOST_WAVE_SOURCE 1 + +// disable stupid compiler warnings +#include <boost/config/warning_disable.hpp> + +#include <string> +#include <boost/assert.hpp> +#include <boost/static_assert.hpp> + +#include <boost/wave/wave_config.hpp> +#include <boost/wave/token_ids.hpp> + +// this must occur after all of the includes and before any code appears +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_PREFIX +#endif + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { +namespace wave { + +/////////////////////////////////////////////////////////////////////////////// +// return a token name +BOOST_WAVE_STRINGTYPE +get_token_name(token_id tokid) +{ +// Table of token names +// +// Please note that the sequence of token names must match the sequence of +// token id's defined in then enum token_id above. +static char const *tok_names[] = { + /* 256 */ "AND", + /* 257 */ "ANDAND", + /* 258 */ "ASSIGN", + /* 259 */ "ANDASSIGN", + /* 260 */ "OR", + /* 261 */ "ORASSIGN", + /* 262 */ "XOR", + /* 263 */ "XORASSIGN", + /* 264 */ "COMMA", + /* 265 */ "COLON", + /* 266 */ "DIVIDE", + /* 267 */ "DIVIDEASSIGN", + /* 268 */ "DOT", + /* 269 */ "DOTSTAR", + /* 270 */ "ELLIPSIS", + /* 271 */ "EQUAL", + /* 272 */ "GREATER", + /* 273 */ "GREATEREQUAL", + /* 274 */ "LEFTBRACE", + /* 275 */ "LESS", + /* 276 */ "LESSEQUAL", + /* 277 */ "LEFTPAREN", + /* 278 */ "LEFTBRACKET", + /* 279 */ "MINUS", + /* 280 */ "MINUSASSIGN", + /* 281 */ "MINUSMINUS", + /* 282 */ "PERCENT", + /* 283 */ "PERCENTASSIGN", + /* 284 */ "NOT", + /* 285 */ "NOTEQUAL", + /* 286 */ "OROR", + /* 287 */ "PLUS", + /* 288 */ "PLUSASSIGN", + /* 289 */ "PLUSPLUS", + /* 290 */ "ARROW", + /* 291 */ "ARROWSTAR", + /* 292 */ "QUESTION_MARK", + /* 293 */ "RIGHTBRACE", + /* 294 */ "RIGHTPAREN", + /* 295 */ "RIGHTBRACKET", + /* 296 */ "COLON_COLON", + /* 297 */ "SEMICOLON", + /* 298 */ "SHIFTLEFT", + /* 299 */ "SHIFTLEFTASSIGN", + /* 300 */ "SHIFTRIGHT", + /* 301 */ "SHIFTRIGHTASSIGN", + /* 302 */ "STAR", + /* 303 */ "COMPL", + /* 304 */ "STARASSIGN", + /* 305 */ "ASM", + /* 306 */ "AUTO", + /* 307 */ "BOOL", + /* 308 */ "FALSE", + /* 309 */ "TRUE", + /* 310 */ "BREAK", + /* 311 */ "CASE", + /* 312 */ "CATCH", + /* 313 */ "CHAR", + /* 314 */ "CLASS", + /* 315 */ "CONST", + /* 316 */ "CONSTCAST", + /* 317 */ "CONTINUE", + /* 318 */ "DEFAULT", + /* 319 */ "DELETE", + /* 320 */ "DO", + /* 321 */ "DOUBLE", + /* 322 */ "DYNAMICCAST", + /* 323 */ "ELSE", + /* 324 */ "ENUM", + /* 325 */ "EXPLICIT", + /* 326 */ "EXPORT", + /* 327 */ "EXTERN", + /* 328 */ "FLOAT", + /* 329 */ "FOR", + /* 330 */ "FRIEND", + /* 331 */ "GOTO", + /* 332 */ "IF", + /* 333 */ "INLINE", + /* 334 */ "INT", + /* 335 */ "LONG", + /* 336 */ "MUTABLE", + /* 337 */ "NAMESPACE", + /* 338 */ "NEW", + /* 339 */ "OPERATOR", + /* 340 */ "PRIVATE", + /* 341 */ "PROTECTED", + /* 342 */ "PUBLIC", + /* 343 */ "REGISTER", + /* 344 */ "REINTERPRETCAST", + /* 345 */ "RETURN", + /* 346 */ "SHORT", + /* 347 */ "SIGNED", + /* 348 */ "SIZEOF", + /* 349 */ "STATIC", + /* 350 */ "STATICCAST", + /* 351 */ "STRUCT", + /* 352 */ "SWITCH", + /* 353 */ "TEMPLATE", + /* 354 */ "THIS", + /* 355 */ "THROW", + /* 356 */ "TRY", + /* 357 */ "TYPEDEF", + /* 358 */ "TYPEID", + /* 359 */ "TYPENAME", + /* 360 */ "UNION", + /* 361 */ "UNSIGNED", + /* 362 */ "USING", + /* 363 */ "VIRTUAL", + /* 364 */ "VOID", + /* 365 */ "VOLATILE", + /* 366 */ "WCHART", + /* 367 */ "WHILE", + /* 368 */ "PP_DEFINE", + /* 369 */ "PP_IF", + /* 370 */ "PP_IFDEF", + /* 371 */ "PP_IFNDEF", + /* 372 */ "PP_ELSE", + /* 373 */ "PP_ELIF", + /* 374 */ "PP_ENDIF", + /* 375 */ "PP_ERROR", + /* 376 */ "PP_LINE", + /* 377 */ "PP_PRAGMA", + /* 378 */ "PP_UNDEF", + /* 379 */ "PP_WARNING", + /* 380 */ "IDENTIFIER", + /* 381 */ "OCTALINT", + /* 382 */ "DECIMALINT", + /* 383 */ "HEXAINT", + /* 384 */ "INTLIT", + /* 385 */ "LONGINTLIT", + /* 386 */ "FLOATLIT", + /* 387 */ "CCOMMENT", + /* 388 */ "CPPCOMMENT", + /* 389 */ "CHARLIT", + /* 390 */ "STRINGLIT", + /* 391 */ "CONTLINE", + /* 392 */ "SPACE", + /* 393 */ "SPACE2", + /* 394 */ "NEWLINE", + /* 395 */ "POUND_POUND", + /* 396 */ "POUND", + /* 397 */ "ANY", + /* 398 */ "PP_INCLUDE", + /* 399 */ "PP_QHEADER", + /* 400 */ "PP_HHEADER", + /* 401 */ "EOF", + /* 402 */ "EOI", + /* 403 */ "PP_NUMBER", + + // MS extensions + /* 404 */ "MSEXT_INT8", + /* 405 */ "MSEXT_INT16", + /* 406 */ "MSEXT_INT32", + /* 407 */ "MSEXT_INT64", + /* 408 */ "MSEXT_BASED", + /* 409 */ "MSEXT_DECLSPEC", + /* 410 */ "MSEXT_CDECL", + /* 411 */ "MSEXT_FASTCALL", + /* 412 */ "MSEXT_STDCALL", + /* 413 */ "MSEXT_TRY", + /* 414 */ "MSEXT_EXCEPT", + /* 415 */ "MSEXT_FINALLY", + /* 416 */ "MSEXT_LEAVE", + /* 417 */ "MSEXT_INLINE", + /* 418 */ "MSEXT_ASM", + /* 419 */ "MSEXT_REGION", + /* 420 */ "MSEXT_ENDREGION", + + /* 421 */ "IMPORT", + + /* 422 */ "ALIGNAS", + /* 423 */ "ALIGNOF", + /* 424 */ "CHAR16_T", + /* 425 */ "CHAR32_T", + /* 426 */ "CONSTEXPR", + /* 427 */ "DECLTYPE", + /* 428 */ "NOEXCEPT", + /* 429 */ "NULLPTR", + /* 430 */ "STATIC_ASSERT", + /* 431 */ "THREADLOCAL", + /* 432 */ "RAWSTRINGLIT", + }; + + // make sure, I have not forgotten any commas (as I did more than once) + BOOST_STATIC_ASSERT( + sizeof(tok_names)/sizeof(tok_names[0]) == T_LAST_TOKEN-T_FIRST_TOKEN + ); + + unsigned int id = BASEID_FROM_TOKEN(tokid)-T_FIRST_TOKEN; + return (id < T_LAST_TOKEN-T_FIRST_TOKEN) ? tok_names[id] : "<UnknownToken>"; +} + +/////////////////////////////////////////////////////////////////////////////// +// return a token name +char const * +get_token_value(token_id tokid) +{ +// Table of token values +// +// Please note that the sequence of token names must match the sequence of +// token id's defined in then enum token_id above. +static char const *tok_values[] = { + /* 256 */ "&", + /* 257 */ "&&", + /* 258 */ "=", + /* 259 */ "&=", + /* 260 */ "|", + /* 261 */ "|=", + /* 262 */ "^", + /* 263 */ "^=", + /* 264 */ ",", + /* 265 */ ":", + /* 266 */ "/", + /* 267 */ "/=", + /* 268 */ ".", + /* 269 */ ".*", + /* 270 */ "...", + /* 271 */ "==", + /* 272 */ ">", + /* 273 */ ">=", + /* 274 */ "{", + /* 275 */ "<", + /* 276 */ "<=", + /* 277 */ "(", + /* 278 */ "[", + /* 279 */ "-", + /* 280 */ "-=", + /* 281 */ "--", + /* 282 */ "%", + /* 283 */ "%=", + /* 284 */ "!", + /* 285 */ "!=", + /* 286 */ "||", + /* 287 */ "+", + /* 288 */ "+=", + /* 289 */ "++", + /* 290 */ "->", + /* 291 */ "->*", + /* 292 */ "?", + /* 293 */ "}", + /* 294 */ ")", + /* 295 */ "]", + /* 296 */ "::", + /* 297 */ ";", + /* 298 */ "<<", + /* 299 */ "<<=", + /* 300 */ ">>", + /* 301 */ ">>=", + /* 302 */ "*", + /* 303 */ "~", + /* 304 */ "*=", + /* 305 */ "asm", + /* 306 */ "auto", + /* 307 */ "bool", + /* 308 */ "false", + /* 309 */ "true", + /* 310 */ "break", + /* 311 */ "case", + /* 312 */ "catch", + /* 313 */ "char", + /* 314 */ "class", + /* 315 */ "const", + /* 316 */ "const_cast", + /* 317 */ "continue", + /* 318 */ "default", + /* 319 */ "delete", + /* 320 */ "do", + /* 321 */ "double", + /* 322 */ "dynamic_cast", + /* 323 */ "else", + /* 324 */ "enum", + /* 325 */ "explicit", + /* 326 */ "export", + /* 327 */ "extern", + /* 328 */ "float", + /* 329 */ "for", + /* 330 */ "friend", + /* 331 */ "goto", + /* 332 */ "if", + /* 333 */ "inline", + /* 334 */ "int", + /* 335 */ "long", + /* 336 */ "mutable", + /* 337 */ "namespace", + /* 338 */ "new", + /* 339 */ "operator", + /* 340 */ "private", + /* 341 */ "protected", + /* 342 */ "public", + /* 343 */ "register", + /* 344 */ "reinterpret_cast", + /* 345 */ "return", + /* 346 */ "short", + /* 347 */ "signed", + /* 348 */ "sizeof", + /* 349 */ "static", + /* 350 */ "static_cast", + /* 351 */ "struct", + /* 352 */ "switch", + /* 353 */ "template", + /* 354 */ "this", + /* 355 */ "throw", + /* 356 */ "try", + /* 357 */ "typedef", + /* 358 */ "typeid", + /* 359 */ "typename", + /* 360 */ "union", + /* 361 */ "unsigned", + /* 362 */ "using", + /* 363 */ "virtual", + /* 364 */ "void", + /* 365 */ "volatile", + /* 366 */ "wchar_t", + /* 367 */ "while", + /* 368 */ "#define", + /* 369 */ "#if", + /* 370 */ "#ifdef", + /* 371 */ "#ifndef", + /* 372 */ "#else", + /* 373 */ "#elif", + /* 374 */ "#endif", + /* 375 */ "#error", + /* 376 */ "#line", + /* 377 */ "#pragma", + /* 378 */ "#undef", + /* 379 */ "#warning", + /* 380 */ "", // identifier + /* 381 */ "", // octalint + /* 382 */ "", // decimalint + /* 383 */ "", // hexlit + /* 384 */ "", // intlit + /* 385 */ "", // longintlit + /* 386 */ "", // floatlit + /* 387 */ "", // ccomment + /* 388 */ "", // cppcomment + /* 389 */ "", // charlit + /* 390 */ "", // stringlit + /* 391 */ "", // contline + /* 392 */ "", // space + /* 393 */ "", // space2 + /* 394 */ "\n", + /* 395 */ "##", + /* 396 */ "#", + /* 397 */ "", // any + /* 398 */ "#include", + /* 399 */ "#include", + /* 400 */ "#include", + /* 401 */ "", // eof + /* 402 */ "", // eoi + /* 403 */ "", // pp-number + + // MS extensions + /* 404 */ "__int8", + /* 405 */ "__int16", + /* 406 */ "__int32", + /* 407 */ "__int64", + /* 408 */ "__based", + /* 409 */ "__declspec", + /* 410 */ "__cdecl", + /* 411 */ "__fastcall", + /* 412 */ "__stdcall", + /* 413 */ "__try", + /* 414 */ "__except", + /* 415 */ "__finally", + /* 416 */ "__leave", + /* 417 */ "__inline", + /* 418 */ "__asm", + /* 419 */ "#region", + /* 420 */ "#endregion", + + /* 421 */ "import", + + /* 422 */ "alignas", + /* 423 */ "alignof", + /* 424 */ "char16_t", + /* 425 */ "char32_t", + /* 426 */ "constexpr", + /* 427 */ "decltype", + /* 428 */ "noexcept", + /* 429 */ "nullptr", + /* 430 */ "static_assert", + /* 431 */ "threadlocal", + /* 432 */ "", // extrawstringlit + }; + + // make sure, I have not forgotten any commas (as I did more than once) + BOOST_STATIC_ASSERT( + sizeof(tok_values)/sizeof(tok_values[0]) == T_LAST_TOKEN-T_FIRST_TOKEN + ); + + unsigned int id = BASEID_FROM_TOKEN(tokid)-T_FIRST_TOKEN; + return (id < T_LAST_TOKEN-T_FIRST_TOKEN) ? tok_values[id] : "<UnknownToken>"; +} + +/////////////////////////////////////////////////////////////////////////////// +} // namespace wave +} // namespace boost + +// the suffix header occurs after all of the code +#ifdef BOOST_HAS_ABI_HEADERS +#include BOOST_ABI_SUFFIX +#endif + + diff --git a/extern/shiny/Readme.txt b/extern/shiny/Readme.txt new file mode 100644 index 0000000000..6133219906 --- /dev/null +++ b/extern/shiny/Readme.txt @@ -0,0 +1,33 @@ +shiny - a shader and material management library for OGRE + +FEATURES + +- High-level layer on top of OGRE's material system. It allows you to generate multiple techniques for all your materials from a set of high-level per-material properties. + +- Several available Macros in shader source files. Just a few examples of the possibilities: binding OGRE auto constants, binding uniforms to material properties, foreach loops (repeat shader source a given number of times), retrieving per-material properties in an #if condition, automatic packing for vertex to fragment passthroughs. These macros allow you to generate even very complex shaders (for example the Ogre::Terrain shader) without assembling them in C++ code. + +- Integrated preprocessor (no, I didn't reinvent the wheel, I used boost::wave which turned out to be an excellent choice) that allows me to blend out macros that shouldn't be in use because e.g. the shader permutation doesn't need this specific feature. + +- User settings integration. They can be set by a C++ interface and retrieved through a macro in shader files. + +- Automatic handling of shader permutations, i.e. shaders are shared between materials in a smart way. + +- An optional "meta-language" (well, actually it's just a small header with some conditional defines) that you may use to compile the same shader source for different target languages. If you don't like it, you can still code in GLSL / CG etc separately. You can also switch between the languages at runtime. + +- On-demand material and shader creation. It uses Ogre's material listener to compile the shaders as soon as they are needed for rendering, and not earlier. + +- Shader changes are fully dynamic and real-time. Changing a user setting will recompile all shaders affected by this setting when they are next needed. + +- Serialization system that extends Ogre's material script system, it uses Ogre's script parser, but also adds some additional properties that are not available in Ogre's material system. + +- A concept called "Configuration" allowing you to create a different set of your shaders, doing the same thing except for some minor differences: the properties that are overridden by the active configuration. Possible uses for this are using simpler shaders (no shadows, no fog etc) when rendering for example realtime reflections or a minimap. You can easily switch between configurations by changing the active Ogre material scheme (for example on a viewport level). + +- Fixed function support. You can globally enable or disable shaders at any time, and for texture units you can specify if they're only needed for the shader-based path (e.g. normal maps) or if they should also be created in the fixed function path. + +LICENSE + +see License.txt + +AUTHOR + +scrawl <scrawl@baseoftrash.de> From 7911f08c53c7da68f1c5283101bc5e3c7b51c5aa Mon Sep 17 00:00:00 2001 From: bwrsandman <mr.sandy.carter@gmail.com> Date: Tue, 6 Nov 2012 13:19:35 -0500 Subject: [PATCH 158/255] Issue #438: set 0 a.m. to be 12 a.m. --- apps/openmw/mwgui/waitdialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 380fb8dd50..73b376f799 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -120,6 +120,7 @@ namespace MWGui int hour = MWBase::Environment::get().getWorld ()->getTimeStamp ().getHour (); bool pm = hour >= 12; if (hour >= 13) hour -= 12; + if (hour == 0) hour = 12; std::string dateTimeText = boost::lexical_cast<std::string>(MWBase::Environment::get().getWorld ()->getDay ()+1) + " " From 9e8eb0d8d30a14f42d62b8f0e31034772c1f4512 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 6 Nov 2012 20:28:49 +0100 Subject: [PATCH 159/255] updated credits.txt --- credits.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/credits.txt b/credits.txt index 45611a2d6f..c9f98861c2 100644 --- a/credits.txt +++ b/credits.txt @@ -25,6 +25,7 @@ Jacob Essex (Yacoby) Jannik Heller (scrawl) Jason Hooks (jhooks) Karl-Felix Glatzer (k1ll) +Leon Saunders (emoose) Lukasz Gromanowski (lgro) Michael Mc Donnell Michael Papageorgiou (werdanith) From bc218759e91ff7d8facb673fd06501a5fe5ac097 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Wed, 7 Nov 2012 15:38:25 +0400 Subject: [PATCH 160/255] forgotten module --- apps/openmw/mwworld/store.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 apps/openmw/mwworld/store.cpp diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp new file mode 100644 index 0000000000..5a6b6a7630 --- /dev/null +++ b/apps/openmw/mwworld/store.cpp @@ -0,0 +1,18 @@ +#include "store.hpp" + +namespace MWWorld +{ + template <> + void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id) { + mStatic.push_back(ESM::Dialogue()); + mStatic.back().mId = id; + mStatic.back().load(esm); + } + + template <> + void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id) { + mStatic.push_back(ESM::Script()); + mStatic.back().load(esm); + StringUtils::toLower(mStatic.back().mId); + } +} From 11c0e6382f34825bf09b327a4bd112afd2ed0aaa Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Wed, 7 Nov 2012 15:41:59 +0400 Subject: [PATCH 161/255] make ESMStore setting up itself after loading --- apps/openmw/mwworld/esmstore.cpp | 1 + apps/openmw/mwworld/esmstore.hpp | 3 ++- apps/openmw/mwworld/worldimp.cpp | 1 - 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index d0f00fa3a1..73f5185c98 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -84,6 +84,7 @@ void ESMStore::load(ESM::ESMReader &esm) cout << *it << " "; cout << endl; */ + setUp(); } void ESMStore::setUp() diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 46c156ffb8..0a6ea01b3b 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -139,7 +139,6 @@ namespace MWWorld } void load(ESM::ESMReader &esm); - void setUp(); template <class T> const Store<T> &get() const { @@ -164,6 +163,8 @@ namespace MWWorld return ptr; } + private: + void setUp(); }; template <> diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 00f16743c7..a482a93173 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -188,7 +188,6 @@ namespace MWWorld mEsm.setEncoding(encoding); mEsm.open (masterPath.string()); mStore.load (mEsm); - mStore.setUp(); mPlayer = new MWWorld::Player (mStore.get<ESM::NPC>().find ("player"), *this); mRendering->attachCameraTo(mPlayer->getPlayer()); From c5a6171aabe6cf49449dd8236660e9575b62a52e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Wed, 7 Nov 2012 19:43:42 +0100 Subject: [PATCH 162/255] cleanup --- apps/openmw/mwworld/store.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 552f6d7606..395abcd837 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -572,7 +572,6 @@ namespace MWWorld ESM::Cell *ptr; if (cell.isExterior()) { std::pair<int, int> key(cell.getGridX(), cell.getGridY()); - DynamicExt::iterator it = mDynamicExt.find(key); // duplicate insertions are avoided by search(ESM::Cell &) std::pair<DynamicExt::iterator, bool> result = @@ -582,7 +581,6 @@ namespace MWWorld mSharedExt.push_back(ptr); } else { std::string key = StringUtils::lowerCase(cell.mName); - DynamicInt::iterator it = mDynamicInt.find(key); // duplicate insertions are avoided by search(ESM::Cell &) std::pair<DynamicInt::iterator, bool> result = From 78740306db6aecdb345174cbdef9faa7d13d1697 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 00:45:45 +0400 Subject: [PATCH 163/255] non-const access to Store<T> from ESMStore --- apps/openmw/mwworld/esmstore.hpp | 230 +++++++++++++++++++++++++++++++ apps/openmw/mwworld/worldimp.cpp | 4 +- 2 files changed, 232 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 0a6ea01b3b..dfe2ac03a2 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -145,6 +145,11 @@ namespace MWWorld throw std::runtime_error("Storage for this type not exist"); } + template <class T> + Store<T> &get() { + throw std::runtime_error("Storage for this type not exist (non-const)"); + } + template <class T> T *insert(const T &x) { Store<T> &store = const_cast<Store<T> &>(get<T>()); @@ -396,6 +401,231 @@ namespace MWWorld inline const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { return mAttributes; } + + template <> + inline Store<ESM::Activator> &ESMStore::get<ESM::Activator>() { + return mActivators; + } + + template <> + inline Store<ESM::Potion> &ESMStore::get<ESM::Potion>() { + return mPotions; + } + + template <> + inline Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() { + return mAppas; + } + + template <> + inline Store<ESM::Armor> &ESMStore::get<ESM::Armor>() { + return mArmors; + } + + template <> + inline Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() { + return mBodyParts; + } + + template <> + inline Store<ESM::Book> &ESMStore::get<ESM::Book>() { + return mBooks; + } + + template <> + inline Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() { + return mBirthSigns; + } + + template <> + inline Store<ESM::Class> &ESMStore::get<ESM::Class>() { + return mClasses; + } + + template <> + inline Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() { + return mClothes; + } + + template <> + inline Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() { + return mContChange; + } + + template <> + inline Store<ESM::Container> &ESMStore::get<ESM::Container>() { + return mContainers; + } + + template <> + inline Store<ESM::Creature> &ESMStore::get<ESM::Creature>() { + return mCreatures; + } + + template <> + inline Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() { + return mCreaChange; + } + + template <> + inline Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() { + return mDialogs; + } + + template <> + inline Store<ESM::Door> &ESMStore::get<ESM::Door>() { + return mDoors; + } + + template <> + inline Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() { + return mEnchants; + } + + template <> + inline Store<ESM::Faction> &ESMStore::get<ESM::Faction>() { + return mFactions; + } + + template <> + inline Store<ESM::Global> &ESMStore::get<ESM::Global>() { + return mGlobals; + } + + template <> + inline Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() { + return mIngreds; + } + + template <> + inline Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() { + return mCreatureLists; + } + + template <> + inline Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() { + return mItemLists; + } + + template <> + inline Store<ESM::Light> &ESMStore::get<ESM::Light>() { + return mLights; + } + + template <> + inline Store<ESM::Tool> &ESMStore::get<ESM::Tool>() { + return mLockpicks; + } + + template <> + inline Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() { + return mMiscItems; + } + + template <> + inline Store<ESM::NPC> &ESMStore::get<ESM::NPC>() { + return mNpcs; + } + + template <> + inline Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() { + return mNpcChange; + } + + template <> + inline Store<ESM::Probe> &ESMStore::get<ESM::Probe>() { + return mProbes; + } + + template <> + inline Store<ESM::Race> &ESMStore::get<ESM::Race>() { + return mRaces; + } + + template <> + inline Store<ESM::Region> &ESMStore::get<ESM::Region>() { + return mRegions; + } + + template <> + inline Store<ESM::Repair> &ESMStore::get<ESM::Repair>() { + return mRepairs; + } + + template <> + inline Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() { + return mSoundGens; + } + + template <> + inline Store<ESM::Sound> &ESMStore::get<ESM::Sound>() { + return mSounds; + } + + template <> + inline Store<ESM::Spell> &ESMStore::get<ESM::Spell>() { + return mSpells; + } + + template <> + inline Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() { + return mStartScripts; + } + + template <> + inline Store<ESM::Static> &ESMStore::get<ESM::Static>() { + return mStatics; + } + + template <> + inline Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() { + return mWeapons; + } + + template <> + inline Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() { + return mGameSettings; + } + + template <> + inline Store<ESM::Script> &ESMStore::get<ESM::Script>() { + return mScripts; + } + + template <> + inline Store<ESM::Cell> &ESMStore::get<ESM::Cell>() { + return mCells; + } + + template <> + inline Store<ESM::Land> &ESMStore::get<ESM::Land>() { + return mLands; + } + + template <> + inline Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() { + return mLandTextures; + } + + template <> + inline Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() { + return mPathgrids; + } + + template <> + inline Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() { + return mMagicEffects; + } + + template <> + inline Store<ESM::Skill> &ESMStore::get<ESM::Skill>() { + return mSkills; + } + + template <> + inline Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() { + return mAttributes; + } } #endif diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 9f5b7520ce..532d335c34 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1058,12 +1058,12 @@ namespace MWWorld // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y); - const ESM::Cell* cell = mStore.get<ESM::Cell>().find(x,y); + const ESM::Cell* cell = ((const ESMStore &) mStore).get<ESM::Cell>().find(x,y); if (cell->mName != "") dest = cell->mName; else { - dest = mStore.get<ESM::Region>().find(cell->mRegion)->mName; + dest = ((const ESMStore &) mStore).get<ESM::Region>().find(cell->mRegion)->mName; } } From 9ab2c16055ccd4c1ef35742f289d5392f83125f2 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Wed, 7 Nov 2012 17:49:45 +0400 Subject: [PATCH 164/255] store created character classes as dynamic records --- apps/openmw/mwgui/charactercreation.cpp | 9 ++++++--- apps/openmw/mwgui/windowmanagerimp.cpp | 4 +--- apps/openmw/mwgui/windowmanagerimp.hpp | 1 - apps/openmw/mwworld/player.cpp | 10 +--------- apps/openmw/mwworld/player.hpp | 8 ++++---- 5 files changed, 12 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 253e0779cb..cdfa43b3b7 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -559,9 +559,12 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) klass.mData.mSkills[i][1] = majorSkills[i]; klass.mData.mSkills[i][0] = minorSkills[i]; } - MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); - mPlayerClass = klass; - mWM->setPlayerClass(klass); + std::pair<std::string, const ESM::Class *> res = + MWBase::Environment::get().getWorld()->createRecord(klass); + + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(*res.second); + mPlayerClass = *res.second; + mWM->setPlayerClass(*res.second); mWM->removeDialog(mCreateClassDialog); mCreateClassDialog = 0; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 8e4187f7f2..dfca049485 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -83,7 +83,6 @@ WindowManager::WindowManager( , mSpellCreationDialog(NULL) , mEnchantingDialog(NULL) , mTrainingWindow(NULL) - , mPlayerClass() , mPlayerName() , mPlayerRaceId() , mPlayerAttributes() @@ -499,8 +498,7 @@ void WindowManager::setValue (const std::string& id, int value) void WindowManager::setPlayerClass (const ESM::Class &class_) { - mPlayerClass = class_; - mStatsWindow->setValue("class", mPlayerClass.mName); + mStatsWindow->setValue("class", class_.mName); } void WindowManager::configureSkills (const SkillList& major, const SkillList& minor) diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index aa796343e9..2e684b5da2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -261,7 +261,6 @@ namespace MWGui /// \todo get rid of this stuff. Move it to the respective UI element classes, if needed. // Various stats about player as needed by window manager - ESM::Class mPlayerClass; std::string mPlayerName; std::string mPlayerRaceId; std::map<int, MWMechanics::Stat<int> > mPlayerAttributes; diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index a1318f7272..5cf1fa3794 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -26,8 +26,7 @@ namespace MWWorld float* playerPos = mPlayer.mData.getPosition().pos; playerPos[0] = playerPos[1] = playerPos[2] = 0; - /// \todo Do not make a copy of classes defined in esm/p records. - mClass = new ESM::Class (*world.getStore().get<ESM::Class>().find (player->mClass)); + mClass = world.getStore().get<ESM::Class>().find (player->mClass); } Player::~Player() @@ -35,13 +34,6 @@ namespace MWWorld delete mClass; } - void Player::setClass (const ESM::Class& class_) - { - ESM::Class *new_class = new ESM::Class (class_); - delete mClass; - mClass = new_class; - } - void Player::setDrawState (MWMechanics::DrawState_ state) { MWWorld::Ptr ptr = getPlayer(); diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 68df2ec6df..a7a0ec430e 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -1,8 +1,6 @@ #ifndef GAME_MWWORLD_PLAYER_H #define GAME_MWWORLD_PLAYER_H -#include "OgreCamera.h" - #include "../mwworld/cellstore.hpp" #include "../mwworld/refdata.hpp" #include "../mwworld/ptr.hpp" @@ -27,7 +25,7 @@ namespace MWWorld bool mMale; std::string mRace; std::string mBirthsign; - ESM::Class *mClass; + const ESM::Class *mClass; bool mAutoMove; int mForwardBackward; public: @@ -67,7 +65,9 @@ namespace MWWorld mBirthsign = birthsign; } - void setClass (const ESM::Class& class_); + void setClass (const ESM::Class& class_) { + mClass = &class_; + } void setDrawState (MWMechanics::DrawState_ state); From 5b9621bca585ab22e3f121346d1a9213d3a254c6 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 01:36:43 +0400 Subject: [PATCH 165/255] store player record data in ESMStore --- apps/openmw/mwbase/world.hpp | 6 ++ apps/openmw/mwgui/charactercreation.cpp | 8 +- apps/openmw/mwgui/levelupdialog.cpp | 2 +- apps/openmw/mwgui/stats_window.cpp | 16 ++-- .../mwmechanics/mechanicsmanagerimp.cpp | 50 +++++++------ apps/openmw/mwworld/player.cpp | 50 ++++++++++--- apps/openmw/mwworld/player.hpp | 74 +++++++++---------- apps/openmw/mwworld/store.hpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 46 ++++++++++++ apps/openmw/mwworld/worldimp.hpp | 6 ++ 10 files changed, 172 insertions(+), 88 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 3a7cb08741..f28ff01847 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -296,6 +296,12 @@ namespace MWBase /// 1 - only waiting \n /// 2 - player is underwater \n /// 3 - enemies are nearby (not implemented) + + /// Update player record part with given value + virtual void updatePlayer(int flag, const std::string &value) = 0; + + /// Update player record part with given value + virtual void updatePlayer(int flag, bool value) = 0; }; } diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index cdfa43b3b7..a054f34ddd 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -559,12 +559,10 @@ void CharacterCreation::onCreateClassDialogDone(WindowBase* parWindow) klass.mData.mSkills[i][1] = majorSkills[i]; klass.mData.mSkills[i][0] = minorSkills[i]; } - std::pair<std::string, const ESM::Class *> res = - MWBase::Environment::get().getWorld()->createRecord(klass); - MWBase::Environment::get().getMechanicsManager()->setPlayerClass(*res.second); - mPlayerClass = *res.second; - mWM->setPlayerClass(*res.second); + MWBase::Environment::get().getMechanicsManager()->setPlayerClass(klass); + mPlayerClass = klass; + mWM->setPlayerClass(klass); mWM->removeDialog(mCreateClassDialog); mCreateClassDialog = 0; diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 399ff74a3a..d8f12bcbb5 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -120,7 +120,7 @@ namespace MWGui setAttributeValues(); // set class image - const ESM::Class& playerClass = MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); + const ESM::Class& playerClass = *MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); // retrieve the ID to this class std::string classId; const MWWorld::Store<ESM::Class> &classes = diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index 9d6842068e..ae86cbf1a7 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -253,7 +253,10 @@ void StatsWindow::onFrame () setFactions(PCstats.getFactionRanks()); - setBirthSign(MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); + const ESM::BirthSign *sign = + MWBase::Environment::get().getWorld()->getPlayer().getBirthsign(); + + setBirthSign((sign != 0) ? sign->mId : ""); if (mChanged) updateSkillArea(); @@ -430,7 +433,7 @@ void StatsWindow::updateSkillArea() // race tooltip const ESM::Race* playerRace = - store.get<ESM::Race>().find (MWBase::Environment::get().getWorld()->getPlayer().getRace()); + MWBase::Environment::get().getWorld()->getPlayer().getRace(); MyGUI::Widget* raceWidget; getWidget(raceWidget, "RaceText"); @@ -440,11 +443,14 @@ void StatsWindow::updateSkillArea() // class tooltip MyGUI::Widget* classWidget; - const ESM::Class& playerClass = MWBase::Environment::get().getWorld()->getPlayer().getClass(); + + const ESM::Class *playerClass = + MWBase::Environment::get().getWorld()->getPlayer().getClass(); + getWidget(classWidget, "ClassText"); - ToolTips::createClassToolTip(classWidget, playerClass); + ToolTips::createClassToolTip(classWidget, *playerClass); getWidget(classWidget, "Class_str"); - ToolTips::createClassToolTip(classWidget, playerClass); + ToolTips::createClassToolTip(classWidget, *playerClass); if (!mFactions.empty()) { diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 94418c5228..7fc7635a47 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -42,9 +42,7 @@ namespace MWMechanics if (mRaceSelected) { const ESM::Race *race = - MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find ( - MWBase::Environment::get().getWorld()->getPlayer().getRace() - ); + MWBase::Environment::get().getWorld()->getPlayer().getRace(); bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); @@ -89,12 +87,11 @@ namespace MWMechanics } // birthsign - if (!MWBase::Environment::get().getWorld()->getPlayer().getBirthsign().empty()) - { - const ESM::BirthSign *sign = - MWBase::Environment::get().getWorld()->getStore().get<ESM::BirthSign>().find ( - MWBase::Environment::get().getWorld()->getPlayer().getBirthsign()); + const ESM::BirthSign *sign = + MWBase::Environment::get().getWorld()->getPlayer().getBirthsign(); + if (sign != 0) + { for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin()); iter!=sign->mPowers.mList.end(); ++iter) { @@ -105,11 +102,12 @@ namespace MWMechanics // class if (mClassSelected) { - const ESM::Class& class_ = MWBase::Environment::get().getWorld()->getPlayer().getClass(); + const ESM::Class *class_ = + MWBase::Environment::get().getWorld()->getPlayer().getClass(); for (int i=0; i<2; ++i) { - int attribute = class_.mData.mAttribute[i]; + int attribute = class_->mData.mAttribute[i]; if (attribute>=0 && attribute<8) { creatureStats.getAttribute(attribute).setBase ( @@ -123,7 +121,7 @@ namespace MWMechanics for (int i2=0; i2<5; ++i2) { - int index = class_.mData.mSkills[i2][i]; + int index = class_->mData.mSkills[i2][i]; if (index>=0 && index<27) { @@ -139,7 +137,7 @@ namespace MWMechanics MWWorld::Store<ESM::Skill>::iterator iter = skills.begin(); for (; iter != skills.end(); ++iter) { - if (iter->mData.mSpecialization==class_.mData.mSpecialization) + if (iter->mData.mSpecialization==class_->mData.mSpecialization) { int index = iter->mIndex; @@ -266,12 +264,12 @@ namespace MWMechanics MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); - MWBase::World *world = MWBase::Environment::get().getWorld(); - MWWorld::Player &player = world->getPlayer(); + MWWorld::Player &player = + MWBase::Environment::get().getWorld()->getPlayer(); winMgr->setValue ("name", player.getName()); - winMgr->setValue ("race", world->getStore().get<ESM::Race>().find (player.getRace())->mName); - winMgr->setValue ("class", player.getClass().mName); + winMgr->setValue ("race", player.getRace()->mName); + winMgr->setValue ("class", player.getClass()->mName); mUpdatePlayer = false; @@ -280,8 +278,8 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = player.getClass().mData.mSkills[i][0]; - majorSkills[i] = player.getClass().mData.mSkills[i][1]; + minorSkills[i] = player.getClass()->mData.mSkills[i][0]; + majorSkills[i] = player.getClass()->mData.mSkills[i][1]; } winMgr->configureSkills (majorSkills, minorSkills); @@ -319,22 +317,26 @@ namespace MWMechanics void MechanicsManager::setPlayerClass (const std::string& id) { - MWBase::Environment::get().getWorld()->getPlayer().setClass ( - *MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find (id) - ); + MWBase::Environment::get().getWorld()->getPlayer().setClass(id); mClassSelected = true; buildPlayer(); mUpdatePlayer = true; } - void MechanicsManager::setPlayerClass (const ESM::Class& class_) + void MechanicsManager::setPlayerClass (const ESM::Class &cls) { - MWBase::Environment::get().getWorld()->getPlayer().setClass (class_); + MWBase::World *world = MWBase::Environment::get().getWorld(); + + std::pair<std::string, const ESM::Class *> res = + world->createRecord(cls); + + world->getPlayer().setClass(res.second->mId); + mClassSelected = true; buildPlayer(); mUpdatePlayer = true; } - + int MechanicsManager::countDeaths (const std::string& id) const { return mActors.countDeaths (id); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 5cf1fa3794..48767a1a17 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -13,25 +13,22 @@ namespace MWWorld { - Player::Player (const ESM::NPC *player, const MWBase::World& world) : - mCellStore (0), mClass (0), - mAutoMove (false), mForwardBackward (0) + Player::Player (const ESM::NPC *player, const MWBase::World& world) + : mCellStore(0), + mClass(0), + mRace(0), + mSign(0), + mAutoMove(false), + mForwardBackward (0) { mPlayer.mBase = player; mPlayer.mRef.mRefID = "player"; - mName = player->mName; - mMale = !(player->mFlags & ESM::NPC::Female); - mRace = player->mRace; float* playerPos = mPlayer.mData.getPosition().pos; playerPos[0] = playerPos[1] = playerPos[2] = 0; mClass = world.getStore().get<ESM::Class>().find (player->mClass); - } - - Player::~Player() - { - delete mClass; + mRace = world.getStore().get<ESM::Race>().find(player->mRace); } void Player::setDrawState (MWMechanics::DrawState_ state) @@ -95,4 +92,35 @@ namespace MWWorld return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState(); } + void Player::setName(const std::string &value) + { + MWBase::Environment::get().getWorld()->updatePlayer(Data_Name, value); + } + + void Player::setGender(bool value) + { + MWBase::Environment::get().getWorld()->updatePlayer(Data_Male, value); + } + + void Player::setRace(const std::string &value) + { + MWBase::World *world = MWBase::Environment::get().getWorld(); + world->updatePlayer(Data_Race, value); + + mRace = world->getStore().get<ESM::Race>().find(value); + } + + void Player::setBirthsign(const std::string &value) + { + MWBase::World *world = MWBase::Environment::get().getWorld(); + mSign = world->getStore().get<ESM::BirthSign>().find(value); + } + + void Player::setClass(const std::string &value) + { + MWBase::World *world = MWBase::Environment::get().getWorld(); + world->updatePlayer(Data_Class, value); + + mClass = world->getStore().get<ESM::Class>().find(value); + } } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index a7a0ec430e..1e6dae2c2e 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -19,21 +19,31 @@ namespace MWWorld /// \brief NPC object representing the player and additional player data class Player { - LiveCellRef<ESM::NPC> mPlayer; - MWWorld::CellStore *mCellStore; - std::string mName; - bool mMale; - std::string mRace; - std::string mBirthsign; - const ESM::Class *mClass; - bool mAutoMove; - int mForwardBackward; + LiveCellRef<ESM::NPC> mPlayer; + MWWorld::CellStore *mCellStore; + + // cached referenced data + const ESM::Class *mClass; + const ESM::Race *mRace; + const ESM::BirthSign *mSign; + + bool mAutoMove; + int mForwardBackward; + public: + enum { + Data_Male, + Data_Name, + Data_Race, + Data_Class, + Data_Sign, + Data_Model, + Data_Head, + Data_Hair + }; Player(const ESM::NPC *player, const MWBase::World& world); - ~Player(); - void setCell (MWWorld::CellStore *cellStore) { mCellStore = cellStore; @@ -45,55 +55,37 @@ namespace MWWorld return ptr; } - void setName (const std::string& name) - { - mName = name; - } - - void setGender (bool male) - { - mMale = male; - } - - void setRace (const std::string& race) - { - mRace = race; - } - - void setBirthsign (const std::string& birthsign) - { - mBirthsign = birthsign; - } - - void setClass (const ESM::Class& class_) { - mClass = &class_; - } + void setName (const std::string& name); + void setGender (bool male); + void setRace (const std::string& race); + void setBirthsign (const std::string& birthsign); + void setClass (const std::string &cls); void setDrawState (MWMechanics::DrawState_ state); std::string getName() const { - return mName; + return mPlayer.mBase->mName; } bool isMale() const { - return mMale; + return (mPlayer.mBase->mFlags & 0x1) == 0; } - std::string getRace() const + const ESM::Race *getRace() const { return mRace; } - std::string getBirthsign() const + const ESM::BirthSign *getBirthsign() const { - return mBirthsign; + return mSign; } - const ESM::Class& getClass() const + const ESM::Class *getClass() const { - return *mClass; + return mClass; } bool getAutoMove() const diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 395abcd837..c645f66135 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -554,7 +554,7 @@ namespace MWWorld ESM::Cell *ptr = search(x, y); if (ptr == 0) { std::ostringstream msg; - msg << "Exterior at (" << x << ", " << y << ") not found (non-const"; + msg << "Exterior at (" << x << ", " << y << ") not found (non-const)"; throw std::runtime_error(msg.str()); } return ptr; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 532d335c34..1c1a3939d0 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1252,4 +1252,50 @@ namespace MWWorld return 0; } + + void World::updatePlayer(int flag, const std::string &value) + { + ESM::NPC *player = mStore.get<ESM::NPC>().find("player"); + + switch (flag) { + case Player::Data_Name: + player->mName = value; + break; + + case Player::Data_Class: + player->mClass = value; + break; + + case Player::Data_Race: + player->mRace = value; + break; + + case Player::Data_Model: + player->mModel = value; + break; + + case Player::Data_Head: + player->mHead = value; + break; + + case Player::Data_Hair: + player->mHair = value; + break; + + default: + break; + } + } + + void World::updatePlayer(int flag, bool value) + { + ESM::NPC *player = mStore.get<ESM::NPC>().find("player"); + + if (flag == Player::Data_Male) { + player->mFlags |= 0x1; + if (value) { + player->mFlags ^= 0x1; + } + } + } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 2b2ad7821f..fe9e961103 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -327,6 +327,12 @@ namespace MWWorld /// 1 - only waiting \n /// 2 - player is underwater \n /// 3 - enemies are nearby (not implemented) + + /// Update player record part with given value + virtual void updatePlayer(int flag, const std::string &value); + + /// Update player record part with given value + virtual void updatePlayer(int flag, bool value); }; } From f818fa1ebfa84a54948b31f9ce4c6de145f036d3 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 01:39:24 +0400 Subject: [PATCH 166/255] minor update since records contains own id --- apps/openmw/mwgui/levelupdialog.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index d8f12bcbb5..099132b8b0 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -120,19 +120,10 @@ namespace MWGui setAttributeValues(); // set class image - const ESM::Class& playerClass = *MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); - // retrieve the ID to this class - std::string classId; - const MWWorld::Store<ESM::Class> &classes = - MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>(); + const ESM::Class *cls = + MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); - MWWorld::Store<ESM::Class>::iterator it = classes.begin(); - for (; it != classes.end(); ++it) - { - if (playerClass.mName == it->mName) - classId = it->mId; - } - mClassImage->setImageTexture ("textures\\levelup\\" + classId + ".dds"); + mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds"); /// \todo replace this with INI-imported texts int level = creatureStats.getLevel ()+1; From 9dc9098fa7a2254f3baeee2acf004babba164551 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 01:52:34 +0400 Subject: [PATCH 167/255] update MWBase::World interface since records contains own id --- apps/openmw/mwbase/world.hpp | 6 +++--- apps/openmw/mwgui/spellcreationdialog.cpp | 4 ++-- apps/openmw/mwmechanics/alchemy.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 5 ++--- apps/openmw/mwworld/worldimp.cpp | 15 ++++++--------- apps/openmw/mwworld/worldimp.hpp | 6 +++--- 6 files changed, 17 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index f28ff01847..611e70fe03 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -230,17 +230,17 @@ namespace MWBase ///< Toggle a render mode. ///< \return Resulting mode - virtual std::pair<std::string, const ESM::Potion *> createRecord (const ESM::Potion& record) + virtual const ESM::Potion *createRecord (const ESM::Potion& record) = 0; ///< Create a new recrod (of type potion) in the ESM store. /// \return ID, pointer to created record - virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record) + virtual const ESM::Spell *createRecord (const ESM::Spell& record) = 0; ///< Create a new recrod (of type spell) in the ESM store. /// \return ID, pointer to created record - virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record) + virtual const ESM::Class *createRecord (const ESM::Class& record) = 0; ///< Create a new recrod (of type class) in the ESM store. /// \return ID, pointer to created record diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 2ece05cb66..25af72c50d 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -336,12 +336,12 @@ namespace MWGui MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); - std::pair<std::string, const ESM::Spell*> result = MWBase::Environment::get().getWorld()->createRecord(mSpell); + const ESM::Spell* spell = MWBase::Environment::get().getWorld()->createRecord(mSpell); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWMechanics::CreatureStats& stats = MWWorld::Class::get(player).getCreatureStats(player); MWMechanics::Spells& spells = stats.getSpells(); - spells.add (result.first); + spells.add (spell->mId); MWBase::Environment::get().getSoundManager()->playSound ("Item Gold Up", 1.0, 1.0); diff --git a/apps/openmw/mwmechanics/alchemy.cpp b/apps/openmw/mwmechanics/alchemy.cpp index 5ccdc5750b..c07c602096 100644 --- a/apps/openmw/mwmechanics/alchemy.cpp +++ b/apps/openmw/mwmechanics/alchemy.cpp @@ -279,7 +279,7 @@ void MWMechanics::Alchemy::addPotion (const std::string& name) newRecord.mEffects.mList = mEffects; - record = MWBase::Environment::get().getWorld()->createRecord (newRecord).second; + record = MWBase::Environment::get().getWorld()->createRecord (newRecord); } MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), record->mId); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 7fc7635a47..3ca3a4ba0d 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -327,10 +327,9 @@ namespace MWMechanics { MWBase::World *world = MWBase::Environment::get().getWorld(); - std::pair<std::string, const ESM::Class *> res = - world->createRecord(cls); + const ESM::Class *ptr = world->createRecord(cls); - world->getPlayer().setClass(res.second->mId); + world->getPlayer().setClass(ptr->mId); mClassSelected = true; buildPlayer(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 1c1a3939d0..e2122aa2d1 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -779,22 +779,19 @@ namespace MWWorld return mRendering->toggleRenderMode (mode); } - std::pair<std::string, const ESM::Potion *> World::createRecord (const ESM::Potion& record) + const ESM::Potion *World::createRecord (const ESM::Potion& record) { - const ESM::Potion *ptr = mStore.insert(record); - return std::make_pair(ptr->mId, ptr); + return mStore.insert(record); } - std::pair<std::string, const ESM::Class *> World::createRecord (const ESM::Class& record) + const ESM::Class *World::createRecord (const ESM::Class& record) { - const ESM::Class *ptr = mStore.insert(record); - return std::make_pair(ptr->mId, ptr); + return mStore.insert(record); } - std::pair<std::string, const ESM::Spell *> World::createRecord (const ESM::Spell& record) + const ESM::Spell *World::createRecord (const ESM::Spell& record) { - const ESM::Spell *ptr = mStore.insert(record); - return std::make_pair(ptr->mId, ptr); + return mStore.insert(record); } const ESM::Cell *World::createRecord (const ESM::Cell& record) diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index fe9e961103..123ad1f87e 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -250,15 +250,15 @@ namespace MWWorld ///< Toggle a render mode. ///< \return Resulting mode - virtual std::pair<std::string, const ESM::Potion *> createRecord (const ESM::Potion& record); + virtual const ESM::Potion *createRecord (const ESM::Potion& record); ///< Create a new recrod (of type potion) in the ESM store. /// \return ID, pointer to created record - virtual std::pair<std::string, const ESM::Spell *> createRecord (const ESM::Spell& record); + virtual const ESM::Spell *createRecord (const ESM::Spell& record); ///< Create a new recrod (of type spell) in the ESM store. /// \return ID, pointer to created record - virtual std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record); + virtual const ESM::Class *createRecord (const ESM::Class& record); ///< Create a new recrod (of type class) in the ESM store. /// \return ID, pointer to created record From 2a06d72e32b6fdcb6698d48a89b1703b736a74d7 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 02:27:01 +0400 Subject: [PATCH 168/255] remove unused custom character classes --- apps/openmw/mwworld/worldimp.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index e2122aa2d1..26013e4ffe 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1260,6 +1260,7 @@ namespace MWWorld break; case Player::Data_Class: + mStore.get<ESM::Class>().erase(player->mClass); player->mClass = value; break; From fba32e406c94e13ba23fe8834911f9b520e45895 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 6 Nov 2012 15:26:51 +0100 Subject: [PATCH 169/255] changed OIS includes since OIS_INCLUDE_DIR is already an include directory --- apps/openmw/mwinput/inputmanagerimp.cpp | 2 +- apps/openmw/mwinput/inputmanagerimp.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index c3e1314402..af30c9b04b 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -9,7 +9,7 @@ #include <boost/lexical_cast.hpp> -#include <OIS/OISInputManager.h> +#include <OISInputManager.h> #include <MyGUI_InputManager.h> #include <MyGUI_RenderManager.h> diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 5e6169f689..718d6b76f2 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -42,8 +42,8 @@ namespace OIS class InputManager; } -#include <OIS/OISKeyboard.h> -#include <OIS/OISMouse.h> +#include <OISKeyboard.h> +#include <OISMouse.h> #include <extern/oics/ICSChannelListener.h> #include <extern/oics/ICSInputControlSystem.h> From 83e758ee500a5975b6f1d2c09986b6ffb750cf4f Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 16:37:57 +0400 Subject: [PATCH 170/255] clean up interfaces --- apps/openmw/mwbase/world.hpp | 12 +- apps/openmw/mwgui/levelupdialog.cpp | 7 +- apps/openmw/mwgui/stats_window.cpp | 14 +- .../mwmechanics/mechanicsmanagerimp.cpp | 83 ++++-- .../mwmechanics/mechanicsmanagerimp.hpp | 1 + apps/openmw/mwworld/esmstore.hpp | 259 ++---------------- apps/openmw/mwworld/player.cpp | 38 --- apps/openmw/mwworld/player.hpp | 46 ---- apps/openmw/mwworld/store.hpp | 57 ---- apps/openmw/mwworld/worldimp.cpp | 56 +--- apps/openmw/mwworld/worldimp.hpp | 12 +- 11 files changed, 121 insertions(+), 464 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 611e70fe03..54cb12c59c 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -29,6 +29,7 @@ namespace ESM struct Class; struct Potion; struct Spell; + struct NPC; } namespace MWRender @@ -249,6 +250,11 @@ namespace MWBase ///< Create a new recrod (of type cell) in the ESM store. /// \return ID, pointer to created record + virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0; + ///< Create a new recrod (of type npc) in the ESM store. + ///< \note special treatment for 'player' record + /// \return ID, pointer to created record + virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number = 1) = 0; ///< Run animation for a MW-reference. Calls to this function for references that are @@ -296,12 +302,6 @@ namespace MWBase /// 1 - only waiting \n /// 2 - player is underwater \n /// 3 - enemies are nearby (not implemented) - - /// Update player record part with given value - virtual void updatePlayer(int flag, const std::string &value) = 0; - - /// Update player record part with given value - virtual void updatePlayer(int flag, bool value) = 0; }; } diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index 099132b8b0..45890b89fe 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -108,7 +108,8 @@ namespace MWGui void LevelupDialog::open() { - MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer(); + MWBase::World *world = MWBase::Environment::get().getWorld(); + MWWorld::Ptr player = world->getPlayer().getPlayer(); MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player); MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player); @@ -119,9 +120,11 @@ namespace MWGui setAttributeValues(); + const ESM::NPC *playerData = player.get<ESM::NPC>()->mBase; + // set class image const ESM::Class *cls = - MWBase::Environment::get().getWorld ()->getPlayer ().getClass (); + world->getStore().get<ESM::Class>().find(playerData->mClass); mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds"); diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index ae86cbf1a7..a557539b7d 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -252,12 +252,12 @@ void StatsWindow::onFrame () } setFactions(PCstats.getFactionRanks()); - +/* const ESM::BirthSign *sign = MWBase::Environment::get().getWorld()->getPlayer().getBirthsign(); setBirthSign((sign != 0) ? sign->mId : ""); - +*/ if (mChanged) updateSkillArea(); } @@ -429,11 +429,13 @@ void StatsWindow::updateSkillArea() if (!mMiscSkills.empty()) addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2); - const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); + MWBase::World *world = MWBase::Environment::get().getWorld(); + const MWWorld::ESMStore &store = world->getStore(); + const ESM::NPC *player = + world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; // race tooltip - const ESM::Race* playerRace = - MWBase::Environment::get().getWorld()->getPlayer().getRace(); + const ESM::Race* playerRace = store.get<ESM::Race>().find(player->mRace); MyGUI::Widget* raceWidget; getWidget(raceWidget, "RaceText"); @@ -445,7 +447,7 @@ void StatsWindow::updateSkillArea() MyGUI::Widget* classWidget; const ESM::Class *playerClass = - MWBase::Environment::get().getWorld()->getPlayer().getClass(); + store.get<ESM::Class>().find(player->mClass); getWidget(classWidget, "ClassText"); ToolTips::createClassToolTip(classWidget, *playerClass); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 3ca3a4ba0d..be675d1bdd 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -37,14 +37,17 @@ namespace MWMechanics creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance); creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality); creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck); + + const MWWorld::ESMStore &esmStore = + MWBase::Environment::get().getWorld()->getStore(); // race if (mRaceSelected) { const ESM::Race *race = - MWBase::Environment::get().getWorld()->getPlayer().getRace(); + esmStore.get<ESM::Race>().find(player->mRace); - bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale(); + bool male = (player->mFlags & ESM::NPC::Female) == 0; for (int i=0; i<8; ++i) { @@ -87,11 +90,11 @@ namespace MWMechanics } // birthsign - const ESM::BirthSign *sign = - MWBase::Environment::get().getWorld()->getPlayer().getBirthsign(); - - if (sign != 0) + if (!mSign.empty()) { + const ESM::BirthSign *sign = + esmStore.get<ESM::BirthSign>().find(mSign); + for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin()); iter!=sign->mPowers.mList.end(); ++iter) { @@ -103,7 +106,7 @@ namespace MWMechanics if (mClassSelected) { const ESM::Class *class_ = - MWBase::Environment::get().getWorld()->getPlayer().getClass(); + esmStore.get<ESM::Class>().find(player->mClass); for (int i=0; i<2; ++i) { @@ -132,7 +135,7 @@ namespace MWMechanics } const MWWorld::Store<ESM::Skill> &skills = - MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>(); + esmStore.get<ESM::Skill>(); MWWorld::Store<ESM::Skill>::iterator iter = skills.begin(); for (; iter != skills.end(); ++iter) @@ -263,13 +266,19 @@ namespace MWMechanics // basic player profile; should not change anymore after the creation phase is finished. MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager(); - - MWWorld::Player &player = - MWBase::Environment::get().getWorld()->getPlayer(); + + MWBase::World *world = MWBase::Environment::get().getWorld(); + const ESM::NPC *player = + world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; - winMgr->setValue ("name", player.getName()); - winMgr->setValue ("race", player.getRace()->mName); - winMgr->setValue ("class", player.getClass()->mName); + const ESM::Race *race = + world->getStore().get<ESM::Race>().find(player->mRace); + const ESM::Class *cls = + world->getStore().get<ESM::Class>().find(player->mClass); + + winMgr->setValue ("name", player->mName); + winMgr->setValue ("race", race->mName); + winMgr->setValue ("class", cls->mName); mUpdatePlayer = false; @@ -278,8 +287,8 @@ namespace MWMechanics for (int i=0; i<5; ++i) { - minorSkills[i] = player.getClass()->mData.mSkills[i][0]; - majorSkills[i] = player.getClass()->mData.mSkills[i][1]; + minorSkills[i] = cls->mData.mSkills[i][0]; + majorSkills[i] = cls->mData.mSkills[i][1]; } winMgr->configureSkills (majorSkills, minorSkills); @@ -295,14 +304,33 @@ namespace MWMechanics void MechanicsManager::setPlayerName (const std::string& name) { - MWBase::Environment::get().getWorld()->getPlayer().setName (name); + MWBase::World *world = MWBase::Environment::get().getWorld(); + + ESM::NPC player = + *world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; + player.mName = name; + + world->createRecord(player); + mUpdatePlayer = true; } void MechanicsManager::setPlayerRace (const std::string& race, bool male) { - MWBase::Environment::get().getWorld()->getPlayer().setGender (male); - MWBase::Environment::get().getWorld()->getPlayer().setRace (race); + MWBase::World *world = MWBase::Environment::get().getWorld(); + + ESM::NPC player = + *world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; + + player.mRace = race; + + player.mFlags |= ESM::NPC::Female; + if (male) { + player.mFlags ^= ESM::NPC::Female; + } + + world->createRecord(player); + mRaceSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -310,14 +338,21 @@ namespace MWMechanics void MechanicsManager::setPlayerBirthsign (const std::string& id) { - MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id); + mSign = id; buildPlayer(); mUpdatePlayer = true; } void MechanicsManager::setPlayerClass (const std::string& id) { - MWBase::Environment::get().getWorld()->getPlayer().setClass(id); + MWBase::World *world = MWBase::Environment::get().getWorld(); + + ESM::NPC player = + *world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; + player.mClass = id; + + world->createRecord(player); + mClassSelected = true; buildPlayer(); mUpdatePlayer = true; @@ -329,7 +364,11 @@ namespace MWMechanics const ESM::Class *ptr = world->createRecord(cls); - world->getPlayer().setClass(ptr->mId); + ESM::NPC player = + *world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; + player.mClass = ptr->mId; + + world->createRecord(player); mClassSelected = true; buildPlayer(); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 38536d3bd7..cc4d8c46a9 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -29,6 +29,7 @@ namespace MWMechanics bool mUpdatePlayer; bool mClassSelected; bool mRaceSelected; + std::string mSign; Actors mActors; void buildPlayer(); diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index dfe2ac03a2..9917254ee7 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -146,13 +146,13 @@ namespace MWWorld } template <class T> - Store<T> &get() { - throw std::runtime_error("Storage for this type not exist (non-const)"); - } - - template <class T> - T *insert(const T &x) { + const T *insert(const T &x) { Store<T> &store = const_cast<Store<T> &>(get<T>()); + if (store.search(x.mId) != 0) { + std::ostringstream msg; + msg << "Try to override existing record '" << x.mId << "'"; + throw std::runtime_error(msg.str()); + } T record = x; std::ostringstream id; @@ -173,10 +173,30 @@ namespace MWWorld }; template <> - inline ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) { + inline const ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) { return mCells.insert(cell); } + template <> + inline const ESM::NPC *ESMStore::insert<ESM::NPC>(const ESM::NPC &npc) { + if (StringUtils::ciEqual(npc.mId, "player")) { + return mNpcs.insert(npc); + } else if (mNpcs.search(npc.mId) != 0) { + std::ostringstream msg; + msg << "Try to override existing record '" << npc.mId << "'"; + throw std::runtime_error(msg.str()); + } + ESM::NPC record = npc; + + std::ostringstream id; + id << "$dynamic" << mDynamicCount++; + record.mId = id.str(); + + ESM::NPC *ptr = mNpcs.insert(record); + mIds[ptr->mId] = ESM::REC_NPC_; + return ptr; + } + template <> inline const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const { return mActivators; @@ -401,231 +421,6 @@ namespace MWWorld inline const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const { return mAttributes; } - - template <> - inline Store<ESM::Activator> &ESMStore::get<ESM::Activator>() { - return mActivators; - } - - template <> - inline Store<ESM::Potion> &ESMStore::get<ESM::Potion>() { - return mPotions; - } - - template <> - inline Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() { - return mAppas; - } - - template <> - inline Store<ESM::Armor> &ESMStore::get<ESM::Armor>() { - return mArmors; - } - - template <> - inline Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() { - return mBodyParts; - } - - template <> - inline Store<ESM::Book> &ESMStore::get<ESM::Book>() { - return mBooks; - } - - template <> - inline Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() { - return mBirthSigns; - } - - template <> - inline Store<ESM::Class> &ESMStore::get<ESM::Class>() { - return mClasses; - } - - template <> - inline Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() { - return mClothes; - } - - template <> - inline Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() { - return mContChange; - } - - template <> - inline Store<ESM::Container> &ESMStore::get<ESM::Container>() { - return mContainers; - } - - template <> - inline Store<ESM::Creature> &ESMStore::get<ESM::Creature>() { - return mCreatures; - } - - template <> - inline Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() { - return mCreaChange; - } - - template <> - inline Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() { - return mDialogs; - } - - template <> - inline Store<ESM::Door> &ESMStore::get<ESM::Door>() { - return mDoors; - } - - template <> - inline Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() { - return mEnchants; - } - - template <> - inline Store<ESM::Faction> &ESMStore::get<ESM::Faction>() { - return mFactions; - } - - template <> - inline Store<ESM::Global> &ESMStore::get<ESM::Global>() { - return mGlobals; - } - - template <> - inline Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() { - return mIngreds; - } - - template <> - inline Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() { - return mCreatureLists; - } - - template <> - inline Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() { - return mItemLists; - } - - template <> - inline Store<ESM::Light> &ESMStore::get<ESM::Light>() { - return mLights; - } - - template <> - inline Store<ESM::Tool> &ESMStore::get<ESM::Tool>() { - return mLockpicks; - } - - template <> - inline Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() { - return mMiscItems; - } - - template <> - inline Store<ESM::NPC> &ESMStore::get<ESM::NPC>() { - return mNpcs; - } - - template <> - inline Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() { - return mNpcChange; - } - - template <> - inline Store<ESM::Probe> &ESMStore::get<ESM::Probe>() { - return mProbes; - } - - template <> - inline Store<ESM::Race> &ESMStore::get<ESM::Race>() { - return mRaces; - } - - template <> - inline Store<ESM::Region> &ESMStore::get<ESM::Region>() { - return mRegions; - } - - template <> - inline Store<ESM::Repair> &ESMStore::get<ESM::Repair>() { - return mRepairs; - } - - template <> - inline Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() { - return mSoundGens; - } - - template <> - inline Store<ESM::Sound> &ESMStore::get<ESM::Sound>() { - return mSounds; - } - - template <> - inline Store<ESM::Spell> &ESMStore::get<ESM::Spell>() { - return mSpells; - } - - template <> - inline Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() { - return mStartScripts; - } - - template <> - inline Store<ESM::Static> &ESMStore::get<ESM::Static>() { - return mStatics; - } - - template <> - inline Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() { - return mWeapons; - } - - template <> - inline Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() { - return mGameSettings; - } - - template <> - inline Store<ESM::Script> &ESMStore::get<ESM::Script>() { - return mScripts; - } - - template <> - inline Store<ESM::Cell> &ESMStore::get<ESM::Cell>() { - return mCells; - } - - template <> - inline Store<ESM::Land> &ESMStore::get<ESM::Land>() { - return mLands; - } - - template <> - inline Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() { - return mLandTextures; - } - - template <> - inline Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() { - return mPathgrids; - } - - template <> - inline Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() { - return mMagicEffects; - } - - template <> - inline Store<ESM::Skill> &ESMStore::get<ESM::Skill>() { - return mSkills; - } - - template <> - inline Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() { - return mAttributes; - } } #endif diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 48767a1a17..3414ba4489 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -15,9 +15,6 @@ namespace MWWorld { Player::Player (const ESM::NPC *player, const MWBase::World& world) : mCellStore(0), - mClass(0), - mRace(0), - mSign(0), mAutoMove(false), mForwardBackward (0) { @@ -26,9 +23,6 @@ namespace MWWorld float* playerPos = mPlayer.mData.getPosition().pos; playerPos[0] = playerPos[1] = playerPos[2] = 0; - - mClass = world.getStore().get<ESM::Class>().find (player->mClass); - mRace = world.getStore().get<ESM::Race>().find(player->mRace); } void Player::setDrawState (MWMechanics::DrawState_ state) @@ -91,36 +85,4 @@ namespace MWWorld MWWorld::Ptr ptr = getPlayer(); return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState(); } - - void Player::setName(const std::string &value) - { - MWBase::Environment::get().getWorld()->updatePlayer(Data_Name, value); - } - - void Player::setGender(bool value) - { - MWBase::Environment::get().getWorld()->updatePlayer(Data_Male, value); - } - - void Player::setRace(const std::string &value) - { - MWBase::World *world = MWBase::Environment::get().getWorld(); - world->updatePlayer(Data_Race, value); - - mRace = world->getStore().get<ESM::Race>().find(value); - } - - void Player::setBirthsign(const std::string &value) - { - MWBase::World *world = MWBase::Environment::get().getWorld(); - mSign = world->getStore().get<ESM::BirthSign>().find(value); - } - - void Player::setClass(const std::string &value) - { - MWBase::World *world = MWBase::Environment::get().getWorld(); - world->updatePlayer(Data_Class, value); - - mClass = world->getStore().get<ESM::Class>().find(value); - } } diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 1e6dae2c2e..7c5ac00186 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -22,25 +22,10 @@ namespace MWWorld LiveCellRef<ESM::NPC> mPlayer; MWWorld::CellStore *mCellStore; - // cached referenced data - const ESM::Class *mClass; - const ESM::Race *mRace; - const ESM::BirthSign *mSign; - bool mAutoMove; int mForwardBackward; public: - enum { - Data_Male, - Data_Name, - Data_Race, - Data_Class, - Data_Sign, - Data_Model, - Data_Head, - Data_Hair - }; Player(const ESM::NPC *player, const MWBase::World& world); @@ -55,39 +40,8 @@ namespace MWWorld return ptr; } - void setName (const std::string& name); - void setGender (bool male); - void setRace (const std::string& race); - void setBirthsign (const std::string& birthsign); - void setClass (const std::string &cls); - void setDrawState (MWMechanics::DrawState_ state); - std::string getName() const - { - return mPlayer.mBase->mName; - } - - bool isMale() const - { - return (mPlayer.mBase->mFlags & 0x1) == 0; - } - - const ESM::Race *getRace() const - { - return mRace; - } - - const ESM::BirthSign *getBirthsign() const - { - return mSign; - } - - const ESM::Class *getClass() const - { - return mClass; - } - bool getAutoMove() const { return mAutoMove; diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index c645f66135..00f67c8ea3 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -168,26 +168,6 @@ namespace MWWorld } } - T *search(const std::string &id) { - std::string key = StringUtils::lowerCase(id); - typename Dynamic::iterator dit = mDynamic.find(key); - - if (dit != mDynamic.end()) { - return &dit->second; - } - return 0; - } - - T *find(const std::string &id) { - T *ptr = search(id); - if (ptr == 0) { - std::ostringstream msg; - msg << "Object '" << id << "' not found (non-const)"; - throw std::runtime_error(msg.str()); - } - return ptr; - } - T *insert(const T &item) { std::string id = StringUtils::lowerCase(item.mId); std::pair<typename Dynamic::iterator, bool> result = @@ -523,43 +503,6 @@ namespace MWWorld } } - ESM::Cell *search(const std::string &id) { - std::string key = StringUtils::lowerCase(id); - DynamicInt::iterator it = mDynamicInt.find(key); - if (it != mDynamicInt.end()) { - return &it->second; - } - return 0; - } - - ESM::Cell *find(const std::string &id) { - ESM::Cell *ptr = search(id); - if (ptr == 0) { - std::ostringstream msg; - msg << "Interior '" << id << "' not found (non-const)"; - throw std::runtime_error(msg.str()); - } - return ptr; - } - - ESM::Cell *search(int x, int y) { - DynamicExt::iterator it = mDynamicExt.find(std::make_pair(x, y)); - if (it != mDynamicExt.end()) { - return &it->second; - } - return 0; - } - - ESM::Cell *find(int x, int y) { - ESM::Cell *ptr = search(x, y); - if (ptr == 0) { - std::ostringstream msg; - msg << "Exterior at (" << x << ", " << y << ") not found (non-const)"; - throw std::runtime_error(msg.str()); - } - return ptr; - } - ESM::Cell *insert(const ESM::Cell &cell) { if (search(cell) != 0) { std::ostringstream msg; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 26013e4ffe..af5745744b 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -799,6 +799,11 @@ namespace MWWorld return mStore.insert(record); } + const ESM::NPC *World::createRecord(const ESM::NPC &record) + { + return mStore.insert(record); + } + void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number) { @@ -1055,12 +1060,12 @@ namespace MWWorld // door leads to exterior, use cell name (if any), otherwise translated region name int x,y; positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y); - const ESM::Cell* cell = ((const ESMStore &) mStore).get<ESM::Cell>().find(x,y); + const ESM::Cell* cell = mStore.get<ESM::Cell>().find(x,y); if (cell->mName != "") dest = cell->mName; else { - dest = ((const ESMStore &) mStore).get<ESM::Region>().find(cell->mRegion)->mName; + dest = mStore.get<ESM::Region>().find(cell->mRegion)->mName; } } @@ -1249,51 +1254,4 @@ namespace MWWorld return 0; } - - void World::updatePlayer(int flag, const std::string &value) - { - ESM::NPC *player = mStore.get<ESM::NPC>().find("player"); - - switch (flag) { - case Player::Data_Name: - player->mName = value; - break; - - case Player::Data_Class: - mStore.get<ESM::Class>().erase(player->mClass); - player->mClass = value; - break; - - case Player::Data_Race: - player->mRace = value; - break; - - case Player::Data_Model: - player->mModel = value; - break; - - case Player::Data_Head: - player->mHead = value; - break; - - case Player::Data_Hair: - player->mHair = value; - break; - - default: - break; - } - } - - void World::updatePlayer(int flag, bool value) - { - ESM::NPC *player = mStore.get<ESM::NPC>().find("player"); - - if (flag == Player::Data_Male) { - player->mFlags |= 0x1; - if (value) { - player->mFlags ^= 0x1; - } - } - } } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 123ad1f87e..20590ff0a0 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -266,6 +266,12 @@ namespace MWWorld ///< Create a new recrod (of type cell) in the ESM store. /// \return ID, pointer to created record + virtual const ESM::NPC *createRecord(const ESM::NPC &record); + ///< Create a new recrod (of type npc) in the ESM store. + ///< \note special treatment for 'player' record + /// \return ID, pointer to created record + + virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number = 1); ///< Run animation for a MW-reference. Calls to this function for references that are @@ -327,12 +333,6 @@ namespace MWWorld /// 1 - only waiting \n /// 2 - player is underwater \n /// 3 - enemies are nearby (not implemented) - - /// Update player record part with given value - virtual void updatePlayer(int flag, const std::string &value); - - /// Update player record part with given value - virtual void updatePlayer(int flag, bool value); }; } From 0a883f4492247dfb7e80ebcf000b9aa8c679a8f2 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Thu, 8 Nov 2012 13:38:20 +0100 Subject: [PATCH 171/255] The player can now barter with merchants --- apps/openmw/mwgui/tradewindow.cpp | 76 +++++++++++++++++-- apps/openmw/mwgui/tradewindow.hpp | 3 + .../mwmechanics/mechanicsmanagerimp.cpp | 2 + 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index cd66b46f51..91247a8866 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -11,6 +11,11 @@ #include "../mwworld/inventorystore.hpp" #include "../mwworld/manualref.hpp" +#include "../mwmechanics/creaturestats.hpp" +#include "../mwmechanics/npcstats.hpp" + +#include "../mwworld/player.hpp" + #include "inventorywindow.hpp" namespace MWGui @@ -53,6 +58,8 @@ namespace MWGui mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onCancelButtonClicked); mOfferButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onOfferButtonClicked); + mIncreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onIncreaseButtonClicked); + mDecreaseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &TradeWindow::onDecreaseButtonClicked); setCoord(400, 0, 400, 300); @@ -64,6 +71,7 @@ namespace MWGui setTitle(MWWorld::Class::get(actor).getName(actor)); mCurrentBalance = 0; + mCurrentMerchantOffer = 0; mWindowManager.getInventoryWindow()->startTrade(); @@ -175,6 +183,49 @@ namespace MWGui return; } + if(mCurrentBalance > mCurrentMerchantOffer) + { + /// \todo : if creature.... + //if npc is a creature: reject (no haggle) + + int a = abs(mCurrentMerchantOffer); + int b = abs(mCurrentBalance); + int d = 0; + if (mCurrentMerchantOffer<0) d = int(100 * (a - b) / a); + else d = int(100 * (b - a) / a); + + float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)),100)); + + MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(mPtr).getNpcStats(mPtr); + MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(mPtr).getCreatureStats(mPtr); + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); + MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); + + float a1 = std::min<float>(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float b1 = std::min<float>(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float c1 = std::min<float>(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + float d1 = std::min<float>(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); + float e1 = std::min<float>(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); + float f1 = std::min<float>(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + + float pcTerm = (clampedDisposition - 50 + a1 + b1 + c1) * playerStats.getFatigueTerm(); + float npcTerm = (d1 + e1 + f1) * sellerStats.getFatigueTerm(); + float x = MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fBargainOfferMulti")->getFloat() * d + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fBargainOfferBase")->getFloat(); + if (mCurrentMerchantOffer<0) x += abs(int(pcTerm - npcTerm)); + else x += abs(int(npcTerm - pcTerm)); + + int roll = std::rand()%100 + 1; + if(roll > x) //trade refused + { + /// \todo adjust npc temporary disposition by iBarterSuccessDisposition or iBarterFailDisposition + return ; + } + } + + +/// \todo adjust npc temporary disposition by iBarterSuccessDisposition or iBarterFailDisposition + // success! make the item transfer. transferBoughtItems(); mWindowManager.getInventoryWindow()->transferBoughtItems(); @@ -199,6 +250,20 @@ namespace MWGui mWindowManager.removeGuiMode(GM_Barter); } + void TradeWindow::onIncreaseButtonClicked(MyGUI::Widget* _sender) + { + if(mCurrentBalance<=-1) mCurrentBalance -= 1; + if(mCurrentBalance>=1) mCurrentBalance += 1; + updateLabels(); + } + + void TradeWindow::onDecreaseButtonClicked(MyGUI::Widget* _sender) + { + if(mCurrentBalance<-1) mCurrentBalance += 1; + if(mCurrentBalance>1) mCurrentBalance -= 1; + updateLabels(); + } + void TradeWindow::updateLabels() { mPlayerGold->setCaptionWithReplacing("#{sYourGold} " + boost::lexical_cast<std::string>(mWindowManager.getInventoryWindow()->getPlayerGold())); @@ -317,20 +382,17 @@ namespace MWGui void TradeWindow::sellToNpc(MWWorld::Ptr item, int count) { - /// \todo price adjustment depending on merchantile skill - - mCurrentBalance -= MWWorld::Class::get(item).getValue(item) * count - + MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); + mCurrentBalance -= MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); + mCurrentMerchantOffer -= MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); updateLabels(); } void TradeWindow::buyFromNpc(MWWorld::Ptr item, int count) { - mCurrentBalance += MWWorld::Class::get(item).getValue(item) * count - - MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); - + mCurrentBalance += MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); + mCurrentMerchantOffer += MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); updateLabels(); } diff --git a/apps/openmw/mwgui/tradewindow.hpp b/apps/openmw/mwgui/tradewindow.hpp index 4ec55045c5..db386d8b6f 100644 --- a/apps/openmw/mwgui/tradewindow.hpp +++ b/apps/openmw/mwgui/tradewindow.hpp @@ -55,11 +55,14 @@ namespace MWGui MyGUI::TextBox* mMerchantGold; int mCurrentBalance; + int mCurrentMerchantOffer; void onWindowResize(MyGUI::Window* _sender); void onFilterChanged(MyGUI::Widget* _sender); void onOfferButtonClicked(MyGUI::Widget* _sender); void onCancelButtonClicked(MyGUI::Widget* _sender); + void onIncreaseButtonClicked(MyGUI::Widget* _sender); + void onDecreaseButtonClicked(MyGUI::Widget* _sender); // don't show items that the NPC has equipped in his trade-window. virtual bool ignoreEquippedItems() { return true; } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index b65b7573b4..240937b7ca 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -384,6 +384,8 @@ namespace MWMechanics x += (MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionRankMult")->getFloat() * rank + MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionRankBase")->getFloat()) * MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispFactionMod")->getFloat() * reaction; + + /// \todo implement bounty and disease //x -= MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispCrimeMod") * pcBounty; //if (pc has a disease) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispDiseaseMod"); if (playerSkill.getDrawState() == MWMechanics::DrawState_::DrawState_Weapon) x += MWBase::Environment::get().getWorld()->getStore().gameSettings.find("fDispWeaponDrawn")->getFloat(); From 1502b3f6f8f9ad80ed6b78cdd686c899f2829094 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 14:09:40 +0100 Subject: [PATCH 172/255] Issue #219: Begin of refactoring; added filter class (doesn't do anything yet) --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 21 ++++++++++----- apps/openmw/mwdialogue/filter.cpp | 10 +++++++ apps/openmw/mwdialogue/filter.hpp | 26 +++++++++++++++++++ 4 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 apps/openmw/mwdialogue/filter.cpp create mode 100644 apps/openmw/mwdialogue/filter.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index b9ce26a661..29f5f2ccce 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -34,7 +34,7 @@ add_openmw_dir (mwgui ) add_openmw_dir (mwdialogue - dialoguemanagerimp journalimp journalentry quest topic + dialoguemanagerimp journalimp journalentry quest topic filter ) add_openmw_dir (mwscript diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 772a1914dc..5838b8c0dd 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -39,6 +39,8 @@ #include "../mwclass/npc.hpp" #include "../mwmechanics/npcstats.hpp" +#include "filter.hpp" + namespace { std::string toLower (const std::string& name) @@ -370,9 +372,7 @@ namespace MWDialogue return true; case '6': // dead -{ -std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name))<<std::endl; -} + return selectCompare<int,int> (comp, MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name)), select.mI); @@ -653,6 +653,8 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); + Filter filter (actor); + MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) { @@ -662,7 +664,7 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); iter!=it->mInfo.end(); ++iter) { - if (isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter) && isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) { if (!iter->mSound.empty()) { @@ -755,6 +757,7 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); + Filter filter (mActor); MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) @@ -764,7 +767,7 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); iter!=it->mInfo.end(); ++iter) { - if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { mActorKnownTopics.push_back(toLower(it->mId)); //does the player know the topic? @@ -841,10 +844,12 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe ESM::Dialogue ndialogue = mDialogueMap[keyword]; if(ndialogue.mType == ESM::Dialogue::Topic) { + Filter filter (mActor); + for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { std::string text = iter->mResponse; std::string script = iter->mResultScript; @@ -886,10 +891,12 @@ std::cout<<"### "<<name<<", "<<select.mI<<", "<<MWBase::Environment::get().getMe ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; if(ndialogue.mType == ESM::Dialogue::Topic) { + Filter filter (mActor); + for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if (isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) { mChoiceMap.clear(); mChoice = -1; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp new file mode 100644 index 0000000000..982062e5bf --- /dev/null +++ b/apps/openmw/mwdialogue/filter.cpp @@ -0,0 +1,10 @@ + +#include "filter.hpp" + +MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {} + +bool MWDialogue::Filter::operator() (const ESM::DialInfo& dialogue) +{ + + return true; +} diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp new file mode 100644 index 0000000000..5193937820 --- /dev/null +++ b/apps/openmw/mwdialogue/filter.hpp @@ -0,0 +1,26 @@ +#ifndef GAME_MWDIALOGUE_FILTER_H +#define GAME_MWDIALOGUE_FILTER_H + +#include "../mwworld/ptr.hpp" + +namespace ESM +{ + struct DialInfo; +} + +namespace MWDialogue +{ + class Filter + { + MWWorld::Ptr mActor; + + public: + + Filter (const MWWorld::Ptr& actor); + + bool operator() (const ESM::DialInfo& dialogue); + ///< \return does the dialogue match? + }; +} + +#endif From 662054acf4a2ee13542a4dde9208be2da4597fc8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 14:55:31 +0100 Subject: [PATCH 173/255] Issue #219: moved checks for various dialogue info fields from DialogueManager to Filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 96 +-------------- apps/openmw/mwdialogue/filter.cpp | 111 +++++++++++++++++- apps/openmw/mwdialogue/filter.hpp | 8 +- components/esm/loadinfo.hpp | 8 +- 4 files changed, 121 insertions(+), 102 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 5838b8c0dd..37f3260c63 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -482,101 +482,7 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const { - bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); - - // actor id - if (!info.mActor.empty()) - if (toLower (info.mActor)!=MWWorld::Class::get (actor).getId (actor)) - return false; - - //NPC race - if (!info.mRace.empty()) - { - if (isCreature) - return false; - - MWWorld::LiveCellRef<ESM::NPC> *cellRef = actor.get<ESM::NPC>(); - - if (!cellRef) - return false; - - if (toLower (info.mRace)!=toLower (cellRef->mBase->mRace)) - return false; - } - - //NPC class - if (!info.mClass.empty()) - { - if (isCreature) - return false; - - MWWorld::LiveCellRef<ESM::NPC> *cellRef = actor.get<ESM::NPC>(); - - if (!cellRef) - return false; - - if (toLower (info.mClass)!=toLower (cellRef->mBase->mClass)) - return false; - } - - //NPC faction - if (!info.mNpcFaction.empty()) - { - if (isCreature) - return false; - - //MWWorld::Class npcClass = MWWorld::Class::get(actor); - MWMechanics::NpcStats stats = MWWorld::Class::get(actor).getNpcStats(actor); - std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.mNpcFaction)); - if(it!=stats.getFactionRanks().end()) - { - //check rank - if(it->second < (int)info.mData.mRank) return false; - } - else - { - //not in the faction - return false; - } - } - - // TODO check player faction - if(!info.mPcFaction.empty()) - { - MWMechanics::NpcStats stats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); - std::map<std::string,int>::iterator it = stats.getFactionRanks().find(toLower(info.mPcFaction)); - if(it!=stats.getFactionRanks().end()) - { - //check rank - if(it->second < (int)info.mData.mPCrank) return false; - } - else - { - //not in the faction - return false; - } - } - - //check gender - if (!isCreature) - { - MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - if(npc->mBase->mFlags & npc->mBase->Female) - { - if(static_cast<int> (info.mData.mGender)==0) return false; - } - else - { - if(static_cast<int> (info.mData.mGender)==1) return false; - } - } - - // check cell - if (!info.mCell.empty()) - if (MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell()->mCell->mName != info.mCell) - return false; - - // TODO check DATAstruct + // check DATAstruct for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.mSelects.begin()); iter != info.mSelects.end(); ++iter) if (!isMatching (actor, *iter)) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 982062e5bf..b69a6d7279 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -1,10 +1,117 @@ #include "filter.hpp" -MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {} +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" -bool MWDialogue::Filter::operator() (const ESM::DialInfo& dialogue) +#include "../mwworld/class.hpp" +#include "../mwworld/player.hpp" + +#include "../mwmechanics/npcstats.hpp" + +namespace { + std::string toLower (const std::string& name) + { + std::string lowerCase; + + std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + return lowerCase; + } +} + +bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const +{ + // actor id + if (!info.mActor.empty()) + if (toLower (info.mActor)!=MWWorld::Class::get (mActor).getId (mActor)) + return false; + + bool isCreature = (mActor.getTypeName() != typeid (ESM::NPC).name()); + + // NPC race + if (!info.mRace.empty()) + { + if (isCreature) + return false; + + MWWorld::LiveCellRef<ESM::NPC> *cellRef = mActor.get<ESM::NPC>(); + + if (toLower (info.mRace)!=toLower (cellRef->mBase->mRace)) + return false; + } + + // NPC class + if (!info.mClass.empty()) + { + if (isCreature) + return false; + + MWWorld::LiveCellRef<ESM::NPC> *cellRef = mActor.get<ESM::NPC>(); + + if (toLower (info.mClass)!=toLower (cellRef->mBase->mClass)) + return false; + } + + // NPC faction + if (!info.mNpcFaction.empty()) + { + if (isCreature) + return false; + + MWMechanics::NpcStats& stats = MWWorld::Class::get (mActor).getNpcStats (mActor); + std::map<std::string, int>::iterator iter = stats.getFactionRanks().find (toLower (info.mNpcFaction)); + + if (iter==stats.getFactionRanks().end()) + return false; + + // check rank + if (iter->second < info.mData.mRank) + return false; + } + + // Gender + if (!isCreature) + { + MWWorld::LiveCellRef<ESM::NPC>* npc = mActor.get<ESM::NPC>(); + if (info.mData.mGender==(npc->mBase->mFlags & npc->mBase->Female ? 0 : 1)) + return false; + } + + return true; +} + +bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const +{ + const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + // check player faction + if (!info.mPcFaction.empty()) + { + MWMechanics::NpcStats& stats = MWWorld::Class::get (player).getNpcStats (player); + std::map<std::string,int>::iterator iter = stats.getFactionRanks().find (toLower (info.mPcFaction)); + + if(iter==stats.getFactionRanks().end()) + return false; + + // check rank + if (iter->second < info.mData.mPCrank) + return false; + } + + // check cell + if (!info.mCell.empty()) + if (toLower (player.getCell()->mCell->mName) != toLower (info.mCell)) + return false; return true; } + +MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {} + +bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const +{ + return testActor (info) && testPlayer (info); +} diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index 5193937820..3ca4153b3e 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -14,11 +14,17 @@ namespace MWDialogue { MWWorld::Ptr mActor; + bool testActor (const ESM::DialInfo& info) const; + ///< Is this the right actor for this \a info? + + bool testPlayer (const ESM::DialInfo& info) const; + ///< Do the player and the cell the player is currently in match \a info? + public: Filter (const MWWorld::Ptr& actor); - bool operator() (const ESM::DialInfo& dialogue); + bool operator() (const ESM::DialInfo& info) const; ///< \return does the dialogue match? }; } diff --git a/components/esm/loadinfo.hpp b/components/esm/loadinfo.hpp index f04fe862e2..f1decb9c63 100644 --- a/components/esm/loadinfo.hpp +++ b/components/esm/loadinfo.hpp @@ -32,10 +32,10 @@ struct DialInfo { int mUnknown1; int mDisposition; - char mRank; // Rank of NPC - char mGender; // See Gender enum - char mPCrank; // Player rank - char mUnknown2; + signed char mRank; // Rank of NPC + signed char mGender; // See Gender enum + signed char mPCrank; // Player rank + signed char mUnknown2; }; // 12 bytes DATAstruct mData; From 2a86432887545756c52cd627f7681ab280df3b23 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 18:50:18 +0400 Subject: [PATCH 174/255] store birthsign in MWWorld::Player --- apps/openmw/mwbase/world.hpp | 2 +- apps/openmw/mwgui/stats_window.cpp | 10 +++++----- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 9 ++++++--- apps/openmw/mwmechanics/mechanicsmanagerimp.hpp | 1 - apps/openmw/mwworld/player.hpp | 9 +++++++++ 5 files changed, 21 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 54cb12c59c..199b563da2 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -252,7 +252,7 @@ namespace MWBase virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0; ///< Create a new recrod (of type npc) in the ESM store. - ///< \note special treatment for 'player' record + /// \note special treatment for 'player' record /// \return ID, pointer to created record virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, diff --git a/apps/openmw/mwgui/stats_window.cpp b/apps/openmw/mwgui/stats_window.cpp index a557539b7d..4b47bb0257 100644 --- a/apps/openmw/mwgui/stats_window.cpp +++ b/apps/openmw/mwgui/stats_window.cpp @@ -252,12 +252,12 @@ void StatsWindow::onFrame () } setFactions(PCstats.getFactionRanks()); -/* - const ESM::BirthSign *sign = - MWBase::Environment::get().getWorld()->getPlayer().getBirthsign(); - setBirthSign((sign != 0) ? sign->mId : ""); -*/ + const std::string &signId = + MWBase::Environment::get().getWorld()->getPlayer().getBirthSign(); + + setBirthSign(signId); + if (mChanged) updateSkillArea(); } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index be675d1bdd..50868eeb35 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -90,10 +90,13 @@ namespace MWMechanics } // birthsign - if (!mSign.empty()) + const std::string &signId = + MWBase::Environment::get().getWorld()->getPlayer().getBirthSign(); + + if (!signId.empty()) { const ESM::BirthSign *sign = - esmStore.get<ESM::BirthSign>().find(mSign); + esmStore.get<ESM::BirthSign>().find(signId); for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin()); iter!=sign->mPowers.mList.end(); ++iter) @@ -338,7 +341,7 @@ namespace MWMechanics void MechanicsManager::setPlayerBirthsign (const std::string& id) { - mSign = id; + MWBase::Environment::get().getWorld()->getPlayer().setBirthSign(id); buildPlayer(); mUpdatePlayer = true; } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index cc4d8c46a9..38536d3bd7 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -29,7 +29,6 @@ namespace MWMechanics bool mUpdatePlayer; bool mClassSelected; bool mRaceSelected; - std::string mSign; Actors mActors; void buildPlayer(); diff --git a/apps/openmw/mwworld/player.hpp b/apps/openmw/mwworld/player.hpp index 7c5ac00186..1c1ef76cf0 100644 --- a/apps/openmw/mwworld/player.hpp +++ b/apps/openmw/mwworld/player.hpp @@ -21,6 +21,7 @@ namespace MWWorld { LiveCellRef<ESM::NPC> mPlayer; MWWorld::CellStore *mCellStore; + std::string mSign; bool mAutoMove; int mForwardBackward; @@ -40,6 +41,14 @@ namespace MWWorld return ptr; } + void setBirthSign(const std::string &sign) { + mSign = sign; + } + + const std::string &getBirthSign() const { + return mSign; + } + void setDrawState (MWMechanics::DrawState_ state); bool getAutoMove() const From b5a59c3a07a5b8b2453a3528c21e34cb07db1269 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 19:01:42 +0400 Subject: [PATCH 175/255] minor doxygen comments update --- apps/openmw/mwbase/world.hpp | 11 +++++------ apps/openmw/mwworld/worldimp.hpp | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 199b563da2..5416945e79 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -234,26 +234,25 @@ namespace MWBase virtual const ESM::Potion *createRecord (const ESM::Potion& record) = 0; ///< Create a new recrod (of type potion) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::Spell *createRecord (const ESM::Spell& record) = 0; ///< Create a new recrod (of type spell) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::Class *createRecord (const ESM::Class& record) = 0; ///< Create a new recrod (of type class) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0; ///< Create a new recrod (of type cell) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0; ///< Create a new recrod (of type npc) in the ESM store. - /// \note special treatment for 'player' record - /// \return ID, pointer to created record + /// \return pointer to created record virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number = 1) = 0; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 20590ff0a0..0962c292c7 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -252,24 +252,23 @@ namespace MWWorld virtual const ESM::Potion *createRecord (const ESM::Potion& record); ///< Create a new recrod (of type potion) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::Spell *createRecord (const ESM::Spell& record); ///< Create a new recrod (of type spell) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::Class *createRecord (const ESM::Class& record); ///< Create a new recrod (of type class) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::Cell *createRecord (const ESM::Cell& record); ///< Create a new recrod (of type cell) in the ESM store. - /// \return ID, pointer to created record + /// \return pointer to created record virtual const ESM::NPC *createRecord(const ESM::NPC &record); ///< Create a new recrod (of type npc) in the ESM store. - ///< \note special treatment for 'player' record - /// \return ID, pointer to created record + /// \return pointer to created record virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, From 4614d2bc8ed0d804db910b1545901810be94f0c5 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 16:49:38 +0100 Subject: [PATCH 176/255] Issue #219: added basic select struct analysis and type checking --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 5 -- apps/openmw/mwdialogue/filter.cpp | 46 +++++++++++++- apps/openmw/mwdialogue/filter.hpp | 11 ++++ apps/openmw/mwdialogue/selectwrapper.cpp | 62 +++++++++++++++++++ apps/openmw/mwdialogue/selectwrapper.hpp | 40 ++++++++++++ 6 files changed, 159 insertions(+), 7 deletions(-) create mode 100644 apps/openmw/mwdialogue/selectwrapper.cpp create mode 100644 apps/openmw/mwdialogue/selectwrapper.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 29f5f2ccce..57a417722e 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -34,7 +34,7 @@ add_openmw_dir (mwgui ) add_openmw_dir (mwdialogue - dialoguemanagerimp journalimp journalentry quest topic filter + dialoguemanagerimp journalimp journalentry quest topic filter selectwrapper ) add_openmw_dir (mwscript diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 37f3260c63..37de30c961 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -469,11 +469,6 @@ namespace MWDialogue throw std::runtime_error ( "unsupported variable type in dialogue info select"); return true; - - - default: - - std::cout << "unchecked select: " << type << " " << comp << " " << name << std::endl; } } diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index b69a6d7279..5161ea5ed6 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -9,6 +9,8 @@ #include "../mwmechanics/npcstats.hpp" +#include "selectwrapper.hpp" + namespace { std::string toLower (const std::string& name) @@ -109,9 +111,51 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const return true; } +bool MWDialogue::Filter::testSelectStructs (const ESM::DialInfo& info) const +{ + for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.mSelects.begin()); + iter != info.mSelects.end(); ++iter) + if (!testSelectStruct (*iter)) + return false; + + return true; +} + +bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const +{ + switch (select.getType()) + { + case SelectWrapper::Type_None: return true; + case SelectWrapper::Type_Integer: return select.selectCompare (getSelectStructInteger (select)); + case SelectWrapper::Type_Numeric: return testSelectStructNumeric (select); + } + + return true; +} + +bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) const +{ + switch (select.getFunction()) + { + default: + + throw std::runtime_error ("unknown numeric select function"); + } +} + +int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) const +{ + switch (select.getFunction()) + { + default: + + throw std::runtime_error ("unknown integer select function"); + } +} + MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {} bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const { - return testActor (info) && testPlayer (info); + return testActor (info) && testPlayer (info) && testSelectStructs (info); } diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index 3ca4153b3e..2b8410941e 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -10,6 +10,8 @@ namespace ESM namespace MWDialogue { + class SelectWrapper; + class Filter { MWWorld::Ptr mActor; @@ -20,6 +22,15 @@ namespace MWDialogue bool testPlayer (const ESM::DialInfo& info) const; ///< Do the player and the cell the player is currently in match \a info? + bool testSelectStructs (const ESM::DialInfo& info) const; + ///< Are all select structs matching? + + bool testSelectStruct (const SelectWrapper& select) const; + + bool testSelectStructNumeric (const SelectWrapper& select) const; + + int getSelectStructInteger (const SelectWrapper& select) const; + public: Filter (const MWWorld::Ptr& actor); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp new file mode 100644 index 0000000000..a45c0adc0b --- /dev/null +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -0,0 +1,62 @@ + +#include "selectwrapper.hpp" + +#include <stdexcept> + +namespace +{ + template<typename T1, typename T2> + bool selectCompareImp (char comp, T1 value1, T2 value2) + { + switch (comp) + { + case '0': return value1==value2; + case '1': return value1!=value2; + case '2': return value1>value2; + case '3': return value1>=value2; + case '4': return value1<value2; + case '5': return value1<=value2; + } + + throw std::runtime_error ("unknown compare type in dialogue info select"); + } + + template<typename T> + bool selectCompareImp (const ESM::DialInfo::SelectStruct& select, T value1) + { + if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || + select.mType==ESM::VT_Long) + { + return selectCompareImp (select.mSelectRule[4], value1, select.mI); + } + else if (select.mType==ESM::VT_Float) + { + return selectCompareImp (select.mSelectRule[4], value1, select.mF); + } + else + throw std::runtime_error ( + "unsupported variable type in dialogue info select"); + } +} + +MWDialogue::SelectWrapper::SelectWrapper (const ESM::DialInfo::SelectStruct& select) : mSelect (select) {} + +MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() const +{ + return Function_None; +} + +MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const +{ + return Type_None; +} + +bool MWDialogue::SelectWrapper::selectCompare (int value) const +{ + return selectCompareImp (mSelect, value); +} + +bool MWDialogue::SelectWrapper::selectCompare (float value) const +{ + return selectCompareImp (mSelect, value); +} diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp new file mode 100644 index 0000000000..acc3e9cc47 --- /dev/null +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -0,0 +1,40 @@ +#ifndef GAME_MWDIALOGUE_SELECTWRAPPER_H +#define GAME_MWDIALOGUE_SELECTWRAPPER_H + +#include <components/esm/loadinfo.hpp> + +namespace MWDialogue +{ + class SelectWrapper + { + const ESM::DialInfo::SelectStruct& mSelect; + + public: + + enum Function + { + Function_None + }; + + enum Type + { + Type_None, + Type_Integer, + Type_Numeric + }; + + public: + + SelectWrapper (const ESM::DialInfo::SelectStruct& select); + + Function getFunction() const; + + Type getType() const; + + bool selectCompare (int value) const; + + bool selectCompare (float value) const; + }; +} + +#endif From b412ebd0af9c33585566c60dde59a928f720e891 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 17:01:26 +0100 Subject: [PATCH 177/255] Issue #219: Supoort for inverted select structs --- apps/openmw/mwdialogue/selectwrapper.cpp | 9 +++++++-- apps/openmw/mwdialogue/selectwrapper.hpp | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index a45c0adc0b..704c4c7ef2 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -51,12 +51,17 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const return Type_None; } +bool MWDialogue::SelectWrapper::IsInverted() const +{ + return false; +} + bool MWDialogue::SelectWrapper::selectCompare (int value) const { - return selectCompareImp (mSelect, value); + return selectCompareImp (mSelect, value)!=IsInverted(); // logic XOR } bool MWDialogue::SelectWrapper::selectCompare (float value) const { - return selectCompareImp (mSelect, value); + return selectCompareImp (mSelect, value)!=IsInverted(); // logic XOR } diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index acc3e9cc47..c4d954d533 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -31,6 +31,8 @@ namespace MWDialogue Type getType() const; + bool IsInverted() const; + bool selectCompare (int value) const; bool selectCompare (float value) const; From f5972a3080965a25438b938067d61b5a4f44168b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 17:04:44 +0100 Subject: [PATCH 178/255] Issue #219: Support for boolean select structs --- apps/openmw/mwdialogue/filter.cpp | 11 +++++++++++ apps/openmw/mwdialogue/filter.hpp | 2 ++ apps/openmw/mwdialogue/selectwrapper.cpp | 5 +++++ apps/openmw/mwdialogue/selectwrapper.hpp | 5 ++++- 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 5161ea5ed6..bded2aaec6 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -128,6 +128,7 @@ bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const case SelectWrapper::Type_None: return true; case SelectWrapper::Type_Integer: return select.selectCompare (getSelectStructInteger (select)); case SelectWrapper::Type_Numeric: return testSelectStructNumeric (select); + case SelectWrapper::Type_Boolean: return select.selectCompare (getSelectStructBoolean (select)); } return true; @@ -153,6 +154,16 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con } } +bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) const +{ + switch (select.getFunction()) + { + default: + + throw std::runtime_error ("unknown boolean select function"); + } +} + MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {} bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index 2b8410941e..4263920cb2 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -30,6 +30,8 @@ namespace MWDialogue bool testSelectStructNumeric (const SelectWrapper& select) const; int getSelectStructInteger (const SelectWrapper& select) const; + + bool getSelectStructBoolean (const SelectWrapper& select) const; public: diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 704c4c7ef2..4e740c62f5 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -65,3 +65,8 @@ bool MWDialogue::SelectWrapper::selectCompare (float value) const { return selectCompareImp (mSelect, value)!=IsInverted(); // logic XOR } + +bool MWDialogue::SelectWrapper::selectCompare (bool value) const +{ + return selectCompareImp (mSelect, static_cast<int> (value))!=IsInverted(); // logic XOR +} diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index c4d954d533..f1ac252097 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -20,7 +20,8 @@ namespace MWDialogue { Type_None, Type_Integer, - Type_Numeric + Type_Numeric, + Type_Boolean }; public: @@ -36,6 +37,8 @@ namespace MWDialogue bool selectCompare (int value) const; bool selectCompare (float value) const; + + bool selectCompare (bool value) const; }; } From 235397dde8c3d2cd2864256997362e42976b6708 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 17:29:10 +0100 Subject: [PATCH 179/255] Issue #219: added missing implemented for isInverted function --- apps/openmw/mwdialogue/selectwrapper.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 4e740c62f5..5efb93ed5f 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -53,7 +53,9 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const bool MWDialogue::SelectWrapper::IsInverted() const { - return false; + char type = mSelect.mSelectRule[1]; + + return type=='7' || type=='8' || type=='9' || type=='A' || type=='B' || type=='C'; } bool MWDialogue::SelectWrapper::selectCompare (int value) const From af5fb7916fa5e949695662bb0849c39f7ea3ed53 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 21:07:14 +0400 Subject: [PATCH 180/255] fix searching in store --- apps/openmw/mwworld/store.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 395abcd837..97b61b5287 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -110,7 +110,7 @@ namespace MWWorld typename std::vector<T>::const_iterator it = std::lower_bound(mStatic.begin(), mStatic.end(), item, RecordCmp()); - if (it != mStatic.end() && it->mId == item.mId) { + if (it != mStatic.end() && StringUtils::ciEqual(it->mId, id)) { return &(*it); } From 00a2de432ab6904e993eb7f86be2cb4848cb10d6 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 8 Nov 2012 18:48:07 +0100 Subject: [PATCH 181/255] fix BulletShapeLoader namespace --- .gitignore | 1 + components/nifbullet/bullet_nif_loader.cpp | 6 +++--- components/nifbullet/bullet_nif_loader.hpp | 4 ++-- libs/openengine/bullet/BulletShapeLoader.cpp | 16 +++++++++++----- libs/openengine/bullet/BulletShapeLoader.h | 13 ++++++++++--- 5 files changed, 27 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 26ba80e1ad..9734ac35c3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ Makefile makefile data *.kdev4 +CMakeLists.txt.user diff --git a/components/nifbullet/bullet_nif_loader.cpp b/components/nifbullet/bullet_nif_loader.cpp index d2ec7ca825..42f6a8e683 100644 --- a/components/nifbullet/bullet_nif_loader.cpp +++ b/components/nifbullet/bullet_nif_loader.cpp @@ -69,7 +69,7 @@ btVector3 ManualBulletShapeLoader::getbtVector(Ogre::Vector3 &v) void ManualBulletShapeLoader::loadResource(Ogre::Resource *resource) { - cShape = static_cast<BulletShape *>(resource); + cShape = static_cast<OEngine::Physic::BulletShape *>(resource); resourceName = cShape->getName(); cShape->mCollide = false; mBoundingBox = NULL; @@ -314,8 +314,8 @@ void ManualBulletShapeLoader::handleNiTriShape(Nif::NiTriShape *shape, int flags void ManualBulletShapeLoader::load(const std::string &name,const std::string &group) { // Check if the resource already exists - Ogre::ResourcePtr ptr = BulletShapeManager::getSingleton().getByName(name, group); + Ogre::ResourcePtr ptr = OEngine::Physic::BulletShapeManager::getSingleton().getByName(name, group); if (!ptr.isNull()) return; - BulletShapeManager::getSingleton().create(name,group,true,this); + OEngine::Physic::BulletShapeManager::getSingleton().create(name,group,true,this); } diff --git a/components/nifbullet/bullet_nif_loader.hpp b/components/nifbullet/bullet_nif_loader.hpp index 82ac227a0f..2190fda1b8 100644 --- a/components/nifbullet/bullet_nif_loader.hpp +++ b/components/nifbullet/bullet_nif_loader.hpp @@ -48,7 +48,7 @@ namespace NifBullet /** *Load bulletShape from NIF files. */ -class ManualBulletShapeLoader : public BulletShapeLoader +class ManualBulletShapeLoader : public OEngine::Physic::BulletShapeLoader { public: @@ -104,7 +104,7 @@ private: - BulletShape* cShape;//current shape + OEngine::Physic::BulletShape* cShape;//current shape btTriangleMesh *mTriMesh; btBoxShape *mBoundingBox; btBvhTriangleMeshShape* currentShape;//the shape curently under construction diff --git a/libs/openengine/bullet/BulletShapeLoader.cpp b/libs/openengine/bullet/BulletShapeLoader.cpp index dd3bca692c..1e626f088c 100644 --- a/libs/openengine/bullet/BulletShapeLoader.cpp +++ b/libs/openengine/bullet/BulletShapeLoader.cpp @@ -1,6 +1,8 @@ #include "BulletShapeLoader.h" - +namespace OEngine { +namespace Physic +{ BulletShape::BulletShape(Ogre::ResourceManager* creator, const Ogre::String &name, Ogre::ResourceHandle handle, const Ogre::String &group, bool isManual, @@ -64,17 +66,18 @@ size_t BulletShape::calculateSize() const //============================================================================================================= -template<> BulletShapeManager *Ogre::Singleton<BulletShapeManager>::msSingleton = 0; +BulletShapeManager *BulletShapeManager::sThis = 0; BulletShapeManager *BulletShapeManager::getSingletonPtr() { - return msSingleton; + assert(sThis); + return sThis; } BulletShapeManager &BulletShapeManager::getSingleton() { - assert(msSingleton); - return(*msSingleton); + assert(sThis); + return(*sThis); } BulletShapeManager::BulletShapeManager() @@ -124,3 +127,6 @@ void BulletShapeLoader::loadResource(Ogre::Resource *resource) void BulletShapeLoader::load(const std::string &name,const std::string &group) {} + +} +} diff --git a/libs/openengine/bullet/BulletShapeLoader.h b/libs/openengine/bullet/BulletShapeLoader.h index 21d21777a2..5c70aeab9b 100644 --- a/libs/openengine/bullet/BulletShapeLoader.h +++ b/libs/openengine/bullet/BulletShapeLoader.h @@ -5,8 +5,10 @@ #include <OgreResourceManager.h> #include <btBulletCollisionCommon.h> #include <OgreVector3.h> -//For some reason, Ogre Singleton cannot be used in another namespace, that's why there is no namespace here. -//But the risk of name collision seems pretty low here. + +namespace OEngine { +namespace Physic +{ /** *Define a new resource which describe a Shape usable by bullet.See BulletShapeManager for how to get/use them. @@ -107,7 +109,7 @@ public: *Important Note: i have no idea of what happen if you try to load two time the same resource without unloading. *It won't crash, but it might lead to memory leaks(I don't know how Ogre handle this). So don't do it! */ -class BulletShapeManager : public Ogre::ResourceManager, public Ogre::Singleton<BulletShapeManager> +class BulletShapeManager : public Ogre::ResourceManager { protected: @@ -116,6 +118,8 @@ protected: const Ogre::String &group, bool isManual, Ogre::ManualResourceLoader *loader, const Ogre::NameValuePairList *createParams); + static BulletShapeManager *sThis; + public: BulletShapeManager(); @@ -139,4 +143,7 @@ public: virtual void load(const std::string &name,const std::string &group); }; +} +} + #endif From 867fb620c3c56f3c159e08299797bce559792cc5 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 8 Nov 2012 19:25:06 +0100 Subject: [PATCH 182/255] part 2 --- libs/openengine/bullet/BulletShapeLoader.cpp | 6 +++++- libs/openengine/bullet/BulletShapeLoader.h | 8 ++++++++ libs/openengine/bullet/physic.cpp | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/openengine/bullet/BulletShapeLoader.cpp b/libs/openengine/bullet/BulletShapeLoader.cpp index 1e626f088c..071a5ee8a9 100644 --- a/libs/openengine/bullet/BulletShapeLoader.cpp +++ b/libs/openengine/bullet/BulletShapeLoader.cpp @@ -70,7 +70,6 @@ BulletShapeManager *BulletShapeManager::sThis = 0; BulletShapeManager *BulletShapeManager::getSingletonPtr() { - assert(sThis); return sThis; } @@ -82,6 +81,9 @@ BulletShapeManager &BulletShapeManager::getSingleton() BulletShapeManager::BulletShapeManager() { + assert(!sThis); + sThis = this; + mResourceType = "BulletShape"; // low, because it will likely reference other resources @@ -95,6 +97,8 @@ BulletShapeManager::~BulletShapeManager() { // and this is how we unregister it Ogre::ResourceGroupManager::getSingleton()._unregisterResourceManager(mResourceType); + + sThis = 0; } BulletShapePtr BulletShapeManager::load(const Ogre::String &name, const Ogre::String &group) diff --git a/libs/openengine/bullet/BulletShapeLoader.h b/libs/openengine/bullet/BulletShapeLoader.h index 5c70aeab9b..d9bd5879af 100644 --- a/libs/openengine/bullet/BulletShapeLoader.h +++ b/libs/openengine/bullet/BulletShapeLoader.h @@ -120,6 +120,14 @@ protected: static BulletShapeManager *sThis; +private: + /** \brief Explicit private copy constructor. This is a forbidden operation.*/ + BulletShapeManager(const BulletShapeManager &); + + /** \brief Private operator= . This is a forbidden operation. */ + BulletShapeManager& operator=(const BulletShapeManager &); + + public: BulletShapeManager(); diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index d78e25ce7f..b39ba53a22 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -251,7 +251,6 @@ namespace Physic PhysicEngine::~PhysicEngine() { - HeightFieldContainer::iterator hf_it = mHeightFieldMap.begin(); for (; hf_it != mHeightFieldMap.end(); ++hf_it) { @@ -293,6 +292,8 @@ namespace Physic delete broadphase; delete pairCache; delete mShapeLoader; + + delete BulletShapeManager::getSingletonPtr(); } void PhysicEngine::addHeightField(float* heights, From 3d7146cd5023c8910d6bd4584a57bf57bf053a47 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 8 Nov 2012 19:34:54 +0100 Subject: [PATCH 183/255] don't allow opening a window multiple times, primarily the console --- apps/openmw/mwgui/windowmanagerimp.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index dfca049485..95356f77f5 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -772,6 +772,13 @@ void WindowManager::pushGuiMode(GuiMode mode) if (mode==GM_Inventory && mAllowed==GW_None) return; + + // If this mode already exists somewhere in the stack, just bring it to the front. + if (std::find(mGuiModes.begin(), mGuiModes.end(), mode) != mGuiModes.end()) + { + mGuiModes.erase(std::find(mGuiModes.begin(), mGuiModes.end(), mode)); + } + mGuiModes.push_back(mode); bool gameMode = !isGuiMode(); From c3f0dc0dfb76c75c40e5fbef9657c601900ad768 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Thu, 8 Nov 2012 13:46:24 +0400 Subject: [PATCH 184/255] m prefix for NpcAnimation members --- apps/openmw/mwrender/npcanimation.cpp | 327 +++++++++++++------------- apps/openmw/mwrender/npcanimation.hpp | 95 ++++---- apps/openmw/mwrender/player.cpp | 1 + components/esm/loadnpc.hpp | 4 + 4 files changed, 221 insertions(+), 206 deletions(-) diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 2153b1407f..e6a8006e24 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -17,44 +17,54 @@ using namespace NifOgre; namespace MWRender{ NpcAnimation::~NpcAnimation() { - removeEntities(head); - removeEntities(hair); - removeEntities(neck); - removeEntities(chest); - removeEntities(groin); - removeEntities(skirt); - removeEntities(rHand); - removeEntities(lHand); - removeEntities(rWrist); - removeEntities(lWrist); - removeEntities(rForearm); - removeEntities(lForearm); - removeEntities(rupperArm); - removeEntities(lupperArm); - removeEntities(rfoot); - removeEntities(lfoot); - removeEntities(rAnkle); - removeEntities(lAnkle); - removeEntities(rKnee); - removeEntities(lKnee); - removeEntities(rUpperLeg); - removeEntities(lUpperLeg); - removeEntities(rclavicle); - removeEntities(lclavicle); - removeEntities(tail); + removeEntities(mHead); + removeEntities(mHair); + removeEntities(mNeck); + removeEntities(mChest); + removeEntities(mGroin); + removeEntities(mSkirt); + removeEntities(mHandL); + removeEntities(mHandR); + removeEntities(mWristL); + removeEntities(mWristR); + removeEntities(mForearmL); + removeEntities(mForearmR); + removeEntities(mUpperArmL); + removeEntities(mUpperArmR); + removeEntities(mFootL); + removeEntities(mFootR); + removeEntities(mAnkleL); + removeEntities(mAnkleR); + removeEntities(mKneeL); + removeEntities(mKneeR); + removeEntities(mUpperLegL); + removeEntities(mUpperLegR); + removeEntities(mClavicleL); + removeEntities(mClavicleR); + removeEntities(mTail); } -NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& _inv, int visibilityFlags) - : Animation(), mStateID(-1), mInv(_inv), timeToChange(0), mVisibilityFlags(visibilityFlags), - robe(mInv.end()), helmet(mInv.end()), shirt(mInv.end()), - cuirass(mInv.end()), greaves(mInv.end()), - leftpauldron(mInv.end()), rightpauldron(mInv.end()), - boots(mInv.end()), - leftglove(mInv.end()), rightglove(mInv.end()), skirtiter(mInv.end()), - pants(mInv.end()) +NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWorld::InventoryStore& inv, int visibilityFlags) + : Animation(), + mStateID(-1), + mInv(inv), + mTimeToChange(0), + mVisibilityFlags(visibilityFlags), + mRobe(mInv.end()), + mHelmet(mInv.end()), + mShirt(mInv.end()), + mCuirass(mInv.end()), + mGreaves(mInv.end()), + mPauldronL(mInv.end()), + mPauldronR(mInv.end()), + mBoots(mInv.end()), + mPants(mInv.end()), + mGloveL(mInv.end()), + mGloveR(mInv.end()), + mSkirtIter(mInv.end()) { - MWWorld::LiveCellRef<ESM::NPC> *ref = ptr.get<ESM::NPC>(); + mNpc = ptr.get<ESM::NPC>()->mBase; for (int init = 0; init < 27; init++) { @@ -64,24 +74,18 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - const ESM::Race *race = store.get<ESM::Race>().find(ref->mBase->mRace); + const ESM::Race *race = store.get<ESM::Race>().find(mNpc->mRace); - std::string hairID = ref->mBase->mHair; - std::string headID = ref->mBase->mHead; - headModel = "meshes\\" + store.get<ESM::BodyPart>().find(headID)->mModel; - hairModel = "meshes\\" + store.get<ESM::BodyPart>().find(hairID)->mModel; - npcName = ref->mBase->mName; - - isFemale = !!(ref->mBase->mFlags&ESM::NPC::Female); - isBeast = !!(race->mData.mFlags&ESM::Race::Beast); - - bodyRaceID = "b_n_"+ref->mBase->mRace; - std::transform(bodyRaceID.begin(), bodyRaceID.end(), bodyRaceID.begin(), ::tolower); + mHeadModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHead)->mModel; + mHairModel = "meshes\\" + store.get<ESM::BodyPart>().find(mNpc->mHair)->mModel; + mBodyPrefix = "b_n_" + mNpc->mRace; + std::transform(mBodyPrefix.begin(), mBodyPrefix.end(), mBodyPrefix.begin(), ::tolower); mInsert = node; assert(mInsert); + bool isBeast = (race->mData.mFlags & ESM::Race::Beast) != 0; std::string smodel = (!isBeast ? "meshes\\base_anim.nif" : "meshes\\base_animkna.nif"); mEntityList = NifOgre::NIFLoader::createEntities(mInsert, &mTextKeys, smodel); @@ -125,7 +129,7 @@ NpcAnimation::NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, MWWor } float scale = race->mData.mHeight.mMale; - if (isFemale) { + if (!mNpc->isMale()) { scale = race->mData.mHeight.mFemale; } mInsert->scale(scale, scale, scale); @@ -141,18 +145,18 @@ void NpcAnimation::updateParts() MWWorld::ContainerStoreIterator *iter; int slot; } slotlist[] = { - { &robe, MWWorld::InventoryStore::Slot_Robe }, - { &skirtiter, MWWorld::InventoryStore::Slot_Skirt }, - { &helmet, MWWorld::InventoryStore::Slot_Helmet }, - { &cuirass, MWWorld::InventoryStore::Slot_Cuirass }, - { &greaves, MWWorld::InventoryStore::Slot_Greaves }, - { &leftpauldron, MWWorld::InventoryStore::Slot_LeftPauldron }, - { &rightpauldron, MWWorld::InventoryStore::Slot_RightPauldron }, - { &boots, MWWorld::InventoryStore::Slot_Boots }, - { &leftglove, MWWorld::InventoryStore::Slot_LeftGauntlet }, - { &rightglove, MWWorld::InventoryStore::Slot_RightGauntlet }, - { &shirt, MWWorld::InventoryStore::Slot_Shirt }, - { &pants, MWWorld::InventoryStore::Slot_Pants }, + { &mRobe, MWWorld::InventoryStore::Slot_Robe }, + { &mSkirtIter, MWWorld::InventoryStore::Slot_Skirt }, + { &mHelmet, MWWorld::InventoryStore::Slot_Helmet }, + { &mCuirass, MWWorld::InventoryStore::Slot_Cuirass }, + { &mGreaves, MWWorld::InventoryStore::Slot_Greaves }, + { &mPauldronL, MWWorld::InventoryStore::Slot_LeftPauldron }, + { &mPauldronR, MWWorld::InventoryStore::Slot_RightPauldron }, + { &mBoots, MWWorld::InventoryStore::Slot_Boots }, + { &mGloveL, MWWorld::InventoryStore::Slot_LeftGauntlet }, + { &mGloveR, MWWorld::InventoryStore::Slot_RightGauntlet }, + { &mShirt, MWWorld::InventoryStore::Slot_Shirt }, + { &mPants, MWWorld::InventoryStore::Slot_Pants }, }; for(size_t i = 0;i < sizeof(slotlist)/sizeof(slotlist[0]);i++) { @@ -167,9 +171,9 @@ void NpcAnimation::updateParts() if(apparelChanged) { - if(robe != mInv.end()) + if(mRobe != mInv.end()) { - MWWorld::Ptr ptr = *robe; + MWWorld::Ptr ptr = *mRobe; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; @@ -187,9 +191,9 @@ void NpcAnimation::updateParts() reserveIndividualPart(ESM::PRT_RPauldron, MWWorld::InventoryStore::Slot_Robe, 5); reserveIndividualPart(ESM::PRT_LPauldron, MWWorld::InventoryStore::Slot_Robe, 5); } - if(skirtiter != mInv.end()) + if(mSkirtIter != mInv.end()) { - MWWorld::Ptr ptr = *skirtiter; + MWWorld::Ptr ptr = *mSkirtIter; const ESM::Clothing *clothes = (ptr.get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; @@ -199,103 +203,103 @@ void NpcAnimation::updateParts() reserveIndividualPart(ESM::PRT_LLeg, MWWorld::InventoryStore::Slot_Skirt, 4); } - if(helmet != mInv.end()) + if(mHelmet != mInv.end()) { removeIndividualPart(ESM::PRT_Hair); - const ESM::Armor *armor = (helmet->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mHelmet->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Helmet, 3, parts); } - if(cuirass != mInv.end()) + if(mCuirass != mInv.end()) { - const ESM::Armor *armor = (cuirass->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mCuirass->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Cuirass, 3, parts); } - if(greaves != mInv.end()) + if(mGreaves != mInv.end()) { - const ESM::Armor *armor = (greaves->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mGreaves->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Greaves, 3, parts); } - if(leftpauldron != mInv.end()) + if(mPauldronL != mInv.end()) { - const ESM::Armor *armor = (leftpauldron->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mPauldronL->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftPauldron, 3, parts); } - if(rightpauldron != mInv.end()) + if(mPauldronR != mInv.end()) { - const ESM::Armor *armor = (rightpauldron->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mPauldronR->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightPauldron, 3, parts); } - if(boots != mInv.end()) + if(mBoots != mInv.end()) { - if(boots->getTypeName() == typeid(ESM::Clothing).name()) + if(mBoots->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (boots->get<ESM::Clothing>())->mBase; + const ESM::Clothing *clothes = (mBoots->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 2, parts); } - else if(boots->getTypeName() == typeid(ESM::Armor).name()) + else if(mBoots->getTypeName() == typeid(ESM::Armor).name()) { - const ESM::Armor *armor = (boots->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mBoots->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Boots, 3, parts); } } - if(leftglove != mInv.end()) + if(mGloveL != mInv.end()) { - if(leftglove->getTypeName() == typeid(ESM::Clothing).name()) + if(mGloveL->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (leftglove->get<ESM::Clothing>())->mBase; + const ESM::Clothing *clothes = (mGloveL->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 2, parts); } else { - const ESM::Armor *armor = (leftglove->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mGloveL->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_LeftGauntlet, 3, parts); } } - if(rightglove != mInv.end()) + if(mGloveR != mInv.end()) { - if(rightglove->getTypeName() == typeid(ESM::Clothing).name()) + if(mGloveR->getTypeName() == typeid(ESM::Clothing).name()) { - const ESM::Clothing *clothes = (rightglove->get<ESM::Clothing>())->mBase; + const ESM::Clothing *clothes = (mGloveR->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 2, parts); } else { - const ESM::Armor *armor = (rightglove->get<ESM::Armor>())->mBase; + const ESM::Armor *armor = (mGloveR->get<ESM::Armor>())->mBase; std::vector<ESM::PartReference> parts = armor->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_RightGauntlet, 3, parts); } } - if(shirt != mInv.end()) + if(mShirt != mInv.end()) { - const ESM::Clothing *clothes = (shirt->get<ESM::Clothing>())->mBase; + const ESM::Clothing *clothes = (mShirt->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Shirt, 2, parts); } - if(pants != mInv.end()) + if(mPants != mInv.end()) { - const ESM::Clothing *clothes = (pants->get<ESM::Clothing>())->mBase; + const ESM::Clothing *clothes = (mPants->get<ESM::Clothing>())->mBase; std::vector<ESM::PartReference> parts = clothes->mParts.mParts; addPartGroup(MWWorld::InventoryStore::Slot_Pants, 2, parts); } } if(mPartPriorities[ESM::PRT_Head] < 1) - addOrReplaceIndividualPart(ESM::PRT_Head, -1,1, headModel); + addOrReplaceIndividualPart(ESM::PRT_Head, -1,1, mHeadModel); if(mPartPriorities[ESM::PRT_Hair] < 1 && mPartPriorities[ESM::PRT_Head] <= 1) - addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, hairModel); + addOrReplaceIndividualPart(ESM::PRT_Hair, -1,1, mHairModel); static const struct { ESM::PartReferenceType type; @@ -329,20 +333,21 @@ void NpcAnimation::updateParts() if(mPartPriorities[PartTypeList[i].type] < 1) { const ESM::BodyPart *part = NULL; - bool tryfemale = isFemale; - int ni = 0; - do { - part = store.get<ESM::BodyPart>().search(bodyRaceID+(tryfemale?"_f_":"_m_")+PartTypeList[i].name[ni]); - if(part) break; + const MWWorld::Store<ESM::BodyPart> &partStore = + store.get<ESM::BodyPart>(); - ni ^= 1; - if(ni == 0) - { - if(!tryfemale) - break; - tryfemale = false; + if (!mNpc->isMale()) { + part = partStore.search(mBodyPrefix + "_f_" + PartTypeList[i].name[0]); + if (part == 0) { + part = partStore.search(mBodyPrefix + "_f_" + PartTypeList[i].name[1]); } - } while(1); + } + if (part == 0) { + part = partStore.search(mBodyPrefix + "_m_" + PartTypeList[i].name[0]); + } + if (part == 0) { + part = partStore.search(mBodyPrefix + "_m_" + PartTypeList[i].name[1]); + } if(part) addOrReplaceIndividualPart(PartTypeList[i].type, -1,1, "meshes\\"+part->mModel); @@ -365,12 +370,12 @@ NifOgre::EntityList NpcAnimation::insertBoundedPart(const std::string &mesh, int void NpcAnimation::runAnimation(float timepassed) { - if(timeToChange > .2) + if(mTimeToChange > .2) { - timeToChange = 0; + mTimeToChange = 0; updateParts(); } - timeToChange += timepassed; + mTimeToChange += timepassed; Animation::runAnimation(timepassed); } @@ -395,61 +400,61 @@ void NpcAnimation::removeIndividualPart(int type) mPartslots[type] = -1; if(type == ESM::PRT_Head) //0 - removeEntities(head); + removeEntities(mHead); else if(type == ESM::PRT_Hair) //1 - removeEntities(hair); + removeEntities(mHair); else if(type == ESM::PRT_Neck) //2 - removeEntities(neck); + removeEntities(mNeck); else if(type == ESM::PRT_Cuirass)//3 - removeEntities(chest); + removeEntities(mChest); else if(type == ESM::PRT_Groin)//4 - removeEntities(groin); + removeEntities(mGroin); else if(type == ESM::PRT_Skirt)//5 - removeEntities(skirt); + removeEntities(mSkirt); else if(type == ESM::PRT_RHand)//6 - removeEntities(rHand); + removeEntities(mHandR); else if(type == ESM::PRT_LHand)//7 - removeEntities(lHand); + removeEntities(mHandL); else if(type == ESM::PRT_RWrist)//8 - removeEntities(rWrist); + removeEntities(mWristR); else if(type == ESM::PRT_LWrist) //9 - removeEntities(lWrist); + removeEntities(mWristL); else if(type == ESM::PRT_Shield) //10 { } else if(type == ESM::PRT_RForearm) //11 - removeEntities(rForearm); + removeEntities(mForearmR); else if(type == ESM::PRT_LForearm) //12 - removeEntities(lForearm); + removeEntities(mForearmL); else if(type == ESM::PRT_RUpperarm) //13 - removeEntities(rupperArm); + removeEntities(mUpperArmR); else if(type == ESM::PRT_LUpperarm) //14 - removeEntities(lupperArm); + removeEntities(mUpperArmL); else if(type == ESM::PRT_RFoot) //15 - removeEntities(rfoot); + removeEntities(mFootR); else if(type == ESM::PRT_LFoot) //16 - removeEntities(lfoot); + removeEntities(mFootL); else if(type == ESM::PRT_RAnkle) //17 - removeEntities(rAnkle); + removeEntities(mAnkleR); else if(type == ESM::PRT_LAnkle) //18 - removeEntities(lAnkle); + removeEntities(mAnkleL); else if(type == ESM::PRT_RKnee) //19 - removeEntities(rKnee); + removeEntities(mKneeR); else if(type == ESM::PRT_LKnee) //20 - removeEntities(lKnee); + removeEntities(mKneeL); else if(type == ESM::PRT_RLeg) //21 - removeEntities(rUpperLeg); + removeEntities(mUpperLegR); else if(type == ESM::PRT_LLeg) //22 - removeEntities(lUpperLeg); + removeEntities(mUpperLegL); else if(type == ESM::PRT_RPauldron) //23 - removeEntities(rclavicle); + removeEntities(mClavicleR); else if(type == ESM::PRT_LPauldron) //24 - removeEntities(lclavicle); + removeEntities(mClavicleL); else if(type == ESM::PRT_Weapon) //25 { } else if(type == ESM::PRT_Tail) //26 - removeEntities(tail); + removeEntities(mTail); } void NpcAnimation::reserveIndividualPart(int type, int group, int priority) @@ -482,83 +487,83 @@ bool NpcAnimation::addOrReplaceIndividualPart(int type, int group, int priority, switch(type) { case ESM::PRT_Head: //0 - head = insertBoundedPart(mesh, group, "Head"); + mHead = insertBoundedPart(mesh, group, "Head"); break; case ESM::PRT_Hair: //1 - hair = insertBoundedPart(mesh, group, "Head"); + mHair = insertBoundedPart(mesh, group, "Head"); break; case ESM::PRT_Neck: //2 - neck = insertBoundedPart(mesh, group, "Neck"); + mNeck = insertBoundedPart(mesh, group, "Neck"); break; case ESM::PRT_Cuirass: //3 - chest = insertBoundedPart(mesh, group, "Chest"); + mChest = insertBoundedPart(mesh, group, "Chest"); break; case ESM::PRT_Groin: //4 - groin = insertBoundedPart(mesh, group, "Groin"); + mGroin = insertBoundedPart(mesh, group, "Groin"); break; case ESM::PRT_Skirt: //5 - skirt = insertBoundedPart(mesh, group, "Groin"); + mSkirt = insertBoundedPart(mesh, group, "Groin"); break; case ESM::PRT_RHand: //6 - rHand = insertBoundedPart(mesh, group, "Right Hand"); + mHandR = insertBoundedPart(mesh, group, "Right Hand"); break; case ESM::PRT_LHand: //7 - lHand = insertBoundedPart(mesh, group, "Left Hand"); + mHandL = insertBoundedPart(mesh, group, "Left Hand"); break; case ESM::PRT_RWrist: //8 - rWrist = insertBoundedPart(mesh, group, "Right Wrist"); + mWristR = insertBoundedPart(mesh, group, "Right Wrist"); break; case ESM::PRT_LWrist: //9 - lWrist = insertBoundedPart(mesh, group, "Left Wrist"); + mWristL = insertBoundedPart(mesh, group, "Left Wrist"); break; case ESM::PRT_Shield: //10 break; case ESM::PRT_RForearm: //11 - rForearm = insertBoundedPart(mesh, group, "Right Forearm"); + mForearmR = insertBoundedPart(mesh, group, "Right Forearm"); break; case ESM::PRT_LForearm: //12 - lForearm = insertBoundedPart(mesh, group, "Left Forearm"); + mForearmL = insertBoundedPart(mesh, group, "Left Forearm"); break; case ESM::PRT_RUpperarm: //13 - rupperArm = insertBoundedPart(mesh, group, "Right Upper Arm"); + mUpperArmR = insertBoundedPart(mesh, group, "Right Upper Arm"); break; case ESM::PRT_LUpperarm: //14 - lupperArm = insertBoundedPart(mesh, group, "Left Upper Arm"); + mUpperArmL = insertBoundedPart(mesh, group, "Left Upper Arm"); break; case ESM::PRT_RFoot: //15 - rfoot = insertBoundedPart(mesh, group, "Right Foot"); + mFootR = insertBoundedPart(mesh, group, "Right Foot"); break; case ESM::PRT_LFoot: //16 - lfoot = insertBoundedPart(mesh, group, "Left Foot"); + mFootL = insertBoundedPart(mesh, group, "Left Foot"); break; case ESM::PRT_RAnkle: //17 - rAnkle = insertBoundedPart(mesh, group, "Right Ankle"); + mAnkleR = insertBoundedPart(mesh, group, "Right Ankle"); break; case ESM::PRT_LAnkle: //18 - lAnkle = insertBoundedPart(mesh, group, "Left Ankle"); + mAnkleL = insertBoundedPart(mesh, group, "Left Ankle"); break; case ESM::PRT_RKnee: //19 - rKnee = insertBoundedPart(mesh, group, "Right Knee"); + mKneeR = insertBoundedPart(mesh, group, "Right Knee"); break; case ESM::PRT_LKnee: //20 - lKnee = insertBoundedPart(mesh, group, "Left Knee"); + mKneeL = insertBoundedPart(mesh, group, "Left Knee"); break; case ESM::PRT_RLeg: //21 - rUpperLeg = insertBoundedPart(mesh, group, "Right Upper Leg"); + mUpperLegR = insertBoundedPart(mesh, group, "Right Upper Leg"); break; case ESM::PRT_LLeg: //22 - lUpperLeg = insertBoundedPart(mesh, group, "Left Upper Leg"); + mUpperLegL = insertBoundedPart(mesh, group, "Left Upper Leg"); break; case ESM::PRT_RPauldron: //23 - rclavicle = insertBoundedPart(mesh , group, "Right Clavicle"); + mClavicleR = insertBoundedPart(mesh , group, "Right Clavicle"); break; case ESM::PRT_LPauldron: //24 - lclavicle = insertBoundedPart(mesh, group, "Left Clavicle"); + mClavicleL = insertBoundedPart(mesh, group, "Left Clavicle"); break; case ESM::PRT_Weapon: //25 break; case ESM::PRT_Tail: //26 - tail = insertBoundedPart(mesh, group, "Tail"); + mTail = insertBoundedPart(mesh, group, "Tail"); break; } return true; @@ -570,14 +575,14 @@ void NpcAnimation::addPartGroup(int group, int priority, std::vector<ESM::PartRe { ESM::PartReference &part = parts[i]; - const MWWorld::Store<ESM::BodyPart> &parts = + const MWWorld::Store<ESM::BodyPart> &partStore = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); const ESM::BodyPart *bodypart = 0; - if(isFemale) - bodypart = parts.search(part.mFemale); + if(!mNpc->isMale()) + bodypart = partStore.search(part.mFemale); if(!bodypart) - bodypart = parts.search(part.mMale); + bodypart = partStore.search(part.mMale); if(bodypart) addOrReplaceIndividualPart(part.mPart, group, priority,"meshes\\" + bodypart->mModel); diff --git a/apps/openmw/mwrender/npcanimation.hpp b/apps/openmw/mwrender/npcanimation.hpp index 21edb3be4f..ca76dcc222 100644 --- a/apps/openmw/mwrender/npcanimation.hpp +++ b/apps/openmw/mwrender/npcanimation.hpp @@ -8,6 +8,11 @@ #include "../mwclass/npc.hpp" #include "../mwworld/containerstore.hpp" +namespace ESM +{ + struct NPC; +} + namespace MWRender{ class NpcAnimation: public Animation{ @@ -19,57 +24,57 @@ private: int mPartPriorities[27]; //Bounded Parts - NifOgre::EntityList lclavicle; - NifOgre::EntityList rclavicle; - NifOgre::EntityList rupperArm; - NifOgre::EntityList lupperArm; - NifOgre::EntityList rUpperLeg; - NifOgre::EntityList lUpperLeg; - NifOgre::EntityList lForearm; - NifOgre::EntityList rForearm; - NifOgre::EntityList lWrist; - NifOgre::EntityList rWrist; - NifOgre::EntityList rKnee; - NifOgre::EntityList lKnee; - NifOgre::EntityList neck; - NifOgre::EntityList rAnkle; - NifOgre::EntityList lAnkle; - NifOgre::EntityList groin; - NifOgre::EntityList skirt; - NifOgre::EntityList lfoot; - NifOgre::EntityList rfoot; - NifOgre::EntityList hair; - NifOgre::EntityList rHand; - NifOgre::EntityList lHand; - NifOgre::EntityList head; - NifOgre::EntityList chest; - NifOgre::EntityList tail; + NifOgre::EntityList mClavicleL; + NifOgre::EntityList mClavicleR; + NifOgre::EntityList mUpperArmL; + NifOgre::EntityList mUpperArmR; + NifOgre::EntityList mUpperLegL; + NifOgre::EntityList mUpperLegR; + NifOgre::EntityList mForearmL; + NifOgre::EntityList mForearmR; + NifOgre::EntityList mWristL; + NifOgre::EntityList mWristR; + NifOgre::EntityList mKneeR; + NifOgre::EntityList mKneeL; + NifOgre::EntityList mNeck; + NifOgre::EntityList mAnkleL; + NifOgre::EntityList mAnkleR; + NifOgre::EntityList mGroin; + NifOgre::EntityList mSkirt; + NifOgre::EntityList mFootL; + NifOgre::EntityList mFootR; + NifOgre::EntityList mHair; + NifOgre::EntityList mHandL; + NifOgre::EntityList mHandR; + NifOgre::EntityList mHead; + NifOgre::EntityList mChest; + NifOgre::EntityList mTail; - bool isBeast; - bool isFemale; - std::string headModel; - std::string hairModel; - std::string npcName; - std::string bodyRaceID; - float timeToChange; - MWWorld::ContainerStoreIterator robe; - MWWorld::ContainerStoreIterator helmet; - MWWorld::ContainerStoreIterator shirt; - MWWorld::ContainerStoreIterator cuirass; - MWWorld::ContainerStoreIterator greaves; - MWWorld::ContainerStoreIterator leftpauldron; - MWWorld::ContainerStoreIterator rightpauldron; - MWWorld::ContainerStoreIterator boots; - MWWorld::ContainerStoreIterator pants; - MWWorld::ContainerStoreIterator leftglove; - MWWorld::ContainerStoreIterator rightglove; - MWWorld::ContainerStoreIterator skirtiter; + const ESM::NPC *mNpc; + std::string mHeadModel; + std::string mHairModel; + std::string mBodyPrefix; + + + float mTimeToChange; + MWWorld::ContainerStoreIterator mRobe; + MWWorld::ContainerStoreIterator mHelmet; + MWWorld::ContainerStoreIterator mShirt; + MWWorld::ContainerStoreIterator mCuirass; + MWWorld::ContainerStoreIterator mGreaves; + MWWorld::ContainerStoreIterator mPauldronL; + MWWorld::ContainerStoreIterator mPauldronR; + MWWorld::ContainerStoreIterator mBoots; + MWWorld::ContainerStoreIterator mPants; + MWWorld::ContainerStoreIterator mGloveL; + MWWorld::ContainerStoreIterator mGloveR; + MWWorld::ContainerStoreIterator mSkirtIter; int mVisibilityFlags; public: NpcAnimation(const MWWorld::Ptr& ptr, Ogre::SceneNode* node, - MWWorld::InventoryStore& _inv, int visibilityFlags); + MWWorld::InventoryStore& inv, int visibilityFlags); virtual ~NpcAnimation(); NifOgre::EntityList insertBoundedPart(const std::string &mesh, int group, const std::string &bonename); virtual void runAnimation(float timepassed); diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index bbc75cade1..f2c313e140 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -18,6 +18,7 @@ namespace MWRender : mCamera(camera), mPlayerNode(node), mCameraNode(mPlayerNode->createChildSceneNode()), + mAnimation(0), mFirstPersonView(true), mPreviewMode(false), mFreeLook(true), diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index ee9ef6b0bc..d446ee08fb 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -117,6 +117,10 @@ struct NPC // Implementation moved to load_impl.cpp void load(ESMReader &esm); void save(ESMWriter &esm); + + bool isMale() const { + return (mFlags & Female) == 0; + } }; } #endif From 91afef140ba8705b15a32c5cc8629799e4b32204 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 21:16:49 +0100 Subject: [PATCH 185/255] Issue #219: moved first batch of integer type functions from DialogueManager to Filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 26 -------- apps/openmw/mwdialogue/filter.cpp | 22 +++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 61 ++++++++++++++++++- apps/openmw/mwdialogue/selectwrapper.hpp | 7 ++- 4 files changed, 88 insertions(+), 28 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 37de30c961..3f7f954f6d 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -345,32 +345,6 @@ namespace MWDialogue return true; - case '4'://journal - if(select.mType==ESM::VT_Int) - { - if(!selectCompare<int,int>(comp,MWBase::Environment::get().getJournal()->getJournalIndex(toLower(name)),select.mI)) return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case '5'://item - { - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); - - int sum = 0; - - for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) - if (toLower(iter->getCellRef().mRefID) == toLower(name)) - sum += iter->getRefData().getCount(); - if(!selectCompare<int,int>(comp,sum,select.mI)) return false; - } - - return true; - case '6': // dead return selectCompare<int,int> (comp, diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index bded2aaec6..eca7752e6e 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -3,9 +3,11 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/journal.hpp" #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" +#include "../mwworld/containerstore.hpp" #include "../mwmechanics/npcstats.hpp" @@ -148,6 +150,26 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con { switch (select.getFunction()) { + case SelectWrapper::Function_Journal: + + return MWBase::Environment::get().getJournal()->getJournalIndex (select.getName()); + + case SelectWrapper::Function_Item: + { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); + + int sum = 0; + + std::string name = select.getName(); + + for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) + if (toLower(iter->getCellRef().mRefID) == name) + sum += iter->getRefData().getCount(); + + return sum; + } + default: throw std::runtime_error ("unknown integer select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 5efb93ed5f..8cd739d6a2 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -1,10 +1,23 @@ #include "selectwrapper.hpp" +#include <cctype> + #include <stdexcept> +#include <algorithm> namespace { + std::string toLower (const std::string& name) + { + std::string lowerCase; + + std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), + (int(*)(int)) std::tolower); + + return lowerCase; + } + template<typename T1, typename T2> bool selectCompareImp (char comp, T1 value1, T2 value2) { @@ -43,12 +56,53 @@ MWDialogue::SelectWrapper::SelectWrapper (const ESM::DialInfo::SelectStruct& sel MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() const { + char type = mSelect.mSelectRule[1]; + + switch (type) + { + case '4': return Function_Journal; + case '5': return Function_Item; + } + return Function_None; } MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const { - return Type_None; + static const Function integerFunctions[] = + { + Function_Journal, Function_Item, + Function_None // end marker + }; + + static const Function numericFunctions[] = + { + Function_None // end marker + }; + + static const Function booleanFunctions[] = + { + Function_None // end marker + }; + + Function function = getFunction(); + + if (function==Function_None) + return Type_None; + + for (int i=0; integerFunctions[i]!=Function_None; ++i) + if (integerFunctions[i]==function) + return Type_Integer; + + for (int i=0; numericFunctions[i]!=Function_None; ++i) + if (numericFunctions[i]==function) + return Type_Numeric; + + for (int i=0; booleanFunctions[i]!=Function_None; ++i) + if (booleanFunctions[i]==function) + return Type_Boolean; + + throw std::runtime_error ("failed to determine type of select function"); } bool MWDialogue::SelectWrapper::IsInverted() const @@ -72,3 +126,8 @@ bool MWDialogue::SelectWrapper::selectCompare (bool value) const { return selectCompareImp (mSelect, static_cast<int> (value))!=IsInverted(); // logic XOR } + +std::string MWDialogue::SelectWrapper::getName() const +{ + return toLower (mSelect.mSelectRule.substr (5)); +} diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index f1ac252097..1ba39128e6 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -13,7 +13,9 @@ namespace MWDialogue enum Function { - Function_None + Function_None, + Function_Journal, + Function_Item }; enum Type @@ -39,6 +41,9 @@ namespace MWDialogue bool selectCompare (float value) const; bool selectCompare (bool value) const; + + std::string getName() const; + ///< Return case-smashed name. }; } From e68bb3481e3150bc3b3f70ecaeadb9b3ea32860a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 21:48:17 +0100 Subject: [PATCH 186/255] Issue #219: moved over the second batch of functions (boolean and one integer I forgot last time) --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 82 ------------------- apps/openmw/mwdialogue/filter.cpp | 28 +++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 41 +++++++--- apps/openmw/mwdialogue/selectwrapper.hpp | 13 ++- 4 files changed, 70 insertions(+), 94 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 3f7f954f6d..5d3bebbc0e 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -289,8 +289,6 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const { - bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); - char type = select.mSelectRule[1]; if (type!='0') @@ -345,86 +343,6 @@ namespace MWDialogue return true; - case '6': // dead - - return selectCompare<int,int> (comp, - MWBase::Environment::get().getMechanicsManager()->countDeaths (toLower (name)), select.mI); - - case '7':// not ID - if(select.mType==ESM::VT_String ||select.mType==ESM::VT_Int)//bug in morrowind here? it's not a short, it's a string - { - int isID = int(toLower(name)==toLower(MWWorld::Class::get (actor).getId (actor))); - if (selectCompare<int,int>(comp,!isID,select.mI)) return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case '8':// not faction - if (isCreature) - return false; - - if(select.mType==ESM::VT_Int) - { - MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - int isFaction = int(toLower(npc->mBase->mFaction) == toLower(name)); - if(selectCompare<int,int>(comp,!isFaction,select.mI)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case '9':// not class - if (isCreature) - return false; - - if(select.mType==ESM::VT_Int) - { - MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - int isClass = int(toLower(npc->mBase->mClass) == toLower(name)); - if(selectCompare<int,int>(comp,!isClass,select.mI)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case 'A'://not Race - if (isCreature) - return false; - - if(select.mType==ESM::VT_Int) - { - MWWorld::LiveCellRef<ESM::NPC>* npc = actor.get<ESM::NPC>(); - int isRace = int(toLower(npc->mBase->mRace) == toLower(name)); - if(selectCompare<int,int>(comp,!isRace,select.mI)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case 'B'://not Cell - if(select.mType==ESM::VT_Int) - { - int isCell = int(toLower(actor.getCell()->mCell->mName) == toLower(name)); - if(selectCompare<int,int>(comp,!isCell,select.mI)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - return true; - case 'C'://not local if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || select.mType==ESM::VT_Long) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index eca7752e6e..9d14dbafcb 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -4,6 +4,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/journal.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" @@ -125,6 +126,9 @@ bool MWDialogue::Filter::testSelectStructs (const ESM::DialInfo& info) const bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const { + if (select.isNpcOnly() && mActor.getTypeName()!=typeid (ESM::NPC).name()) + return select.isInverted(); + switch (select.getType()) { case SelectWrapper::Type_None: return true; @@ -169,6 +173,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return sum; } + + case SelectWrapper::Function_Dead: + + return MWBase::Environment::get().getMechanicsManager()->countDeaths (select.getName()); default: @@ -180,6 +188,26 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co { switch (select.getFunction()) { + case SelectWrapper::Function_Id: + + return select.getName()==toLower (MWWorld::Class::get (mActor).getId (mActor)); + + case SelectWrapper::Function_Faction: + + return toLower (mActor.get<ESM::NPC>()->mBase->mFaction)==select.getName(); + + case SelectWrapper::Function_Class: + + return toLower (mActor.get<ESM::NPC>()->mBase->mClass)==select.getName(); + + case SelectWrapper::Function_Race: + + return toLower (mActor.get<ESM::NPC>()->mBase->mRace)==select.getName(); + + case SelectWrapper::Function_Cell: + + return toLower (mActor.getCell()->mCell->mName)==select.getName(); + default: throw std::runtime_error ("unknown boolean select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 8cd739d6a2..90aa77f944 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -62,6 +62,12 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con { case '4': return Function_Journal; case '5': return Function_Item; + case '6': return Function_Dead; + case '7': return Function_Id; + case '8': return Function_Faction; + case '9': return Function_Class; + case 'A': return Function_Race; + case 'B': return Function_Cell; } return Function_None; @@ -71,7 +77,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const { static const Function integerFunctions[] = { - Function_Journal, Function_Item, + Function_Journal, Function_Item, Function_Dead, Function_None // end marker }; @@ -82,14 +88,12 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const static const Function booleanFunctions[] = { + Function_Id, Function_Faction, Function_Class, Function_Race, Function_Cell, Function_None // end marker }; Function function = getFunction(); - - if (function==Function_None) - return Type_None; - + for (int i=0; integerFunctions[i]!=Function_None; ++i) if (integerFunctions[i]==function) return Type_Integer; @@ -102,29 +106,46 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const if (booleanFunctions[i]==function) return Type_Boolean; - throw std::runtime_error ("failed to determine type of select function"); + return Type_None; } -bool MWDialogue::SelectWrapper::IsInverted() const +bool MWDialogue::SelectWrapper::isInverted() const { char type = mSelect.mSelectRule[1]; return type=='7' || type=='8' || type=='9' || type=='A' || type=='B' || type=='C'; } +bool MWDialogue::SelectWrapper::isNpcOnly() const +{ + static const Function functions[] = + { + Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race, + Function_None // end marker + }; + + Function function = getFunction(); + + for (int i=0; functions[i]!=Function_None; ++i) + if (functions[i]==function) + return true; + + return false; +} + bool MWDialogue::SelectWrapper::selectCompare (int value) const { - return selectCompareImp (mSelect, value)!=IsInverted(); // logic XOR + return selectCompareImp (mSelect, value)!=isInverted(); // logic XOR } bool MWDialogue::SelectWrapper::selectCompare (float value) const { - return selectCompareImp (mSelect, value)!=IsInverted(); // logic XOR + return selectCompareImp (mSelect, value)!=isInverted(); // logic XOR } bool MWDialogue::SelectWrapper::selectCompare (bool value) const { - return selectCompareImp (mSelect, static_cast<int> (value))!=IsInverted(); // logic XOR + return selectCompareImp (mSelect, static_cast<int> (value))!=isInverted(); // logic XOR } std::string MWDialogue::SelectWrapper::getName() const diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 1ba39128e6..10a20ef746 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -15,7 +15,13 @@ namespace MWDialogue { Function_None, Function_Journal, - Function_Item + Function_Item, + Function_Dead, + Function_Id, + Function_Faction, + Function_Class, + Function_Race, + Function_Cell }; enum Type @@ -34,7 +40,10 @@ namespace MWDialogue Type getType() const; - bool IsInverted() const; + bool isInverted() const; + + bool isNpcOnly() const; + ///< \attention Do not call any of the select functions for this select struct! bool selectCompare (int value) const; From 4634227f1cbda02c50f0423fc209fadb51447ee0 Mon Sep 17 00:00:00 2001 From: gugus <gus_512@hotmail.com> Date: Thu, 8 Nov 2012 21:50:56 +0100 Subject: [PATCH 187/255] notify the user when the merchant doesn't accept the offer --- apps/openmw/mwgui/tradewindow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 91247a8866..2c42015064 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -218,6 +218,8 @@ namespace MWGui int roll = std::rand()%100 + 1; if(roll > x) //trade refused { + MWBase::Environment::get().getWindowManager()-> + messageBox("#{sNotifyMessage9}", std::vector<std::string>()); /// \todo adjust npc temporary disposition by iBarterSuccessDisposition or iBarterFailDisposition return ; } From e6021a3fe3982acb7f35416aba5a4b43027359b8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 8 Nov 2012 22:11:50 +0100 Subject: [PATCH 188/255] Issue #219: moved checks for local and global variables from DialogueManager to Filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 140 ------------------ apps/openmw/mwdialogue/filter.cpp | 42 ++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 4 + apps/openmw/mwdialogue/selectwrapper.hpp | 4 +- 4 files changed, 49 insertions(+), 141 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 5d3bebbc0e..e12a22247f 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -84,71 +84,6 @@ namespace throw std::runtime_error ("unknown compare type in dialogue info select"); } - template<typename T> - bool checkLocal (char comp, const std::string& name, T value, const MWWorld::Ptr& actor, - const MWWorld::ESMStore& store) - { - std::string scriptName = MWWorld::Class::get (actor).getScript (actor); - - if (scriptName.empty()) - return false; // no script - - const ESM::Script *script = - store.get<ESM::Script>().find (scriptName); - - int i = 0; - - for (; i<static_cast<int> (script->mVarNames.size()); ++i) - if (script->mVarNames[i]==name) - break; - - if (i>=static_cast<int> (script->mVarNames.size())) - return false; // script does not have a variable of this name - - const MWScript::Locals& locals = actor.getRefData().getLocals(); - - if (i<script->mData.mNumShorts) - return selectCompare (comp, locals.mShorts[i], value); - else - i -= script->mData.mNumShorts; - - if (i<script->mData.mNumLongs) - return selectCompare (comp, locals.mLongs[i], value); - else - i -= script->mData.mNumShorts; - - return selectCompare (comp, locals.mFloats.at (i), value); - } - - template<typename T> - bool checkGlobal (char comp, const std::string& name, T value) - { - switch (MWBase::Environment::get().getWorld()->getGlobalVariableType (name)) - { - case 's': - return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mShort, value); - - case 'l': - - return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mLong, value); - - case 'f': - - return selectCompare (comp, MWBase::Environment::get().getWorld()->getGlobalVariable (name).mFloat, value); - - case ' ': - - MWBase::Environment::get().getWorld()->getGlobalVariable (name); // trigger exception - break; - - default: - - throw std::runtime_error ("unsupported gobal variable type"); - } - - return false; - } - //helper function std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) { @@ -289,81 +224,6 @@ namespace MWDialogue bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const { - char type = select.mSelectRule[1]; - - if (type!='0') - { - char comp = select.mSelectRule[4]; - std::string name = select.mSelectRule.substr (5); - std::string function = select.mSelectRule.substr(1,2); - - switch (type) - { - case '1': // function - - return true; // Done elsewhere. - - case '2': // global - - if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || - select.mType==ESM::VT_Long) - { - if (!checkGlobal (comp, toLower (name), select.mI)) - return false; - } - else if (select.mType==ESM::VT_Float) - { - if (!checkGlobal (comp, toLower (name), select.mF)) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case '3': // local - - if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || - select.mType==ESM::VT_Long) - { - if (!checkLocal (comp, toLower (name), select.mI, actor, - MWBase::Environment::get().getWorld()->getStore())) - return false; - } - else if (select.mType==ESM::VT_Float) - { - if (!checkLocal (comp, toLower (name), select.mF, actor, - MWBase::Environment::get().getWorld()->getStore())) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - - return true; - - case 'C'://not local - if (select.mType==ESM::VT_Short || select.mType==ESM::VT_Int || - select.mType==ESM::VT_Long) - { - if (checkLocal (comp, toLower (name), select.mI, actor, - MWBase::Environment::get().getWorld()->getStore())) - return false; - } - else if (select.mType==ESM::VT_Float) - { - if (checkLocal (comp, toLower (name), select.mF, actor, - MWBase::Environment::get().getWorld()->getStore())) - return false; - } - else - throw std::runtime_error ( - "unsupported variable type in dialogue info select"); - return true; - } - } - return true; } diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 9d14dbafcb..4ad7bc1578 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -144,6 +144,48 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c { switch (select.getFunction()) { + case SelectWrapper::Function_Global: + + // internally all globals are float :( + return select.selectCompare ( + MWBase::Environment::get().getWorld()->getGlobalVariable (select.getName()).mFloat); + + case SelectWrapper::Function_Local: + { + std::string scriptName = MWWorld::Class::get (mActor).getScript (mActor); + + if (scriptName.empty()) + return false; // no script + + const ESM::Script *script = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Script>().find (scriptName); + + std::string name = select.getName(); + + int i = 0; + + for (; i<static_cast<int> (script->mVarNames.size()); ++i) + if (script->mVarNames[i]==name) + break; + + if (i>=static_cast<int> (script->mVarNames.size())) + return false; // script does not have a variable of this name + + const MWScript::Locals& locals = mActor.getRefData().getLocals(); + + if (i<script->mData.mNumShorts) + return select.selectCompare (static_cast<int> (locals.mShorts[i])); + + i -= script->mData.mNumShorts; + + if (i<script->mData.mNumLongs) + return select.selectCompare (locals.mLongs[i]); + + i -= script->mData.mNumShorts; + + return select.selectCompare (locals.mFloats.at (i)); + } + default: throw std::runtime_error ("unknown numeric select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 90aa77f944..effb431108 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -60,6 +60,8 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con switch (type) { + case '2': return Function_Global; + case '3': return Function_Local; case '4': return Function_Journal; case '5': return Function_Item; case '6': return Function_Dead; @@ -68,6 +70,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con case '9': return Function_Class; case 'A': return Function_Race; case 'B': return Function_Cell; + case 'C': return Function_Local; } return Function_None; @@ -83,6 +86,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const static const Function numericFunctions[] = { + Function_Global, Function_Local, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 10a20ef746..1bd528be05 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -21,7 +21,9 @@ namespace MWDialogue Function_Faction, Function_Class, Function_Race, - Function_Cell + Function_Cell, + Function_Local, + Function_Global }; enum Type From bf4e855260f75b57b9746a721ee0d04fab68bb1a Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 8 Nov 2012 22:31:08 +0100 Subject: [PATCH 189/255] fixed creatures --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 2 +- apps/openmw/mwgui/dialogue.cpp | 13 ++++++++----- apps/openmw/mwgui/tradewindow.cpp | 19 ++++++++++++------- .../mwmechanics/mechanicsmanagerimp.cpp | 5 +++-- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 62f7df679b..2024c287dc 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -795,7 +795,7 @@ namespace MWDialogue || services & ESM::NPC::Misc) windowServices |= MWGui::DialogueWindow::Service_Trade; - if( !mActor.get<ESM::NPC>()->base->mTransport.empty()) + if(mActor.getTypeName() == typeid(ESM::NPC).name() && !mActor.get<ESM::NPC>()->base->mTransport.empty()) windowServices |= MWGui::DialogueWindow::Service_Travel; if (services & ESM::NPC::Spells) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index f3cc66f380..190a7ddf8c 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -294,10 +294,13 @@ void DialogueWindow::updateOptions() mTopicsList->clear(); mHistory->eraseText(0, mHistory->getTextLength()); - mDispositionBar->setProgressRange(100); - mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); - mDispositionText->eraseText(0, mDispositionText->getTextLength()); - mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154"); + if (mPtr.getTypeName() == typeid(ESM::NPC).name()) + { + mDispositionBar->setProgressRange(100); + mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); + mDispositionText->eraseText(0, mDispositionText->getTextLength()); + mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154"); + } } void DialogueWindow::goodbye() @@ -314,7 +317,7 @@ void DialogueWindow::onReferenceUnavailable() void DialogueWindow::onFrame() { - if(mEnabled) + if(mEnabled && mPtr.getTypeName() == typeid(ESM::NPC).name()) { mDispositionBar->setProgressRange(100); mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 2c42015064..5fe58c7908 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -185,8 +185,13 @@ namespace MWGui if(mCurrentBalance > mCurrentMerchantOffer) { - /// \todo : if creature.... //if npc is a creature: reject (no haggle) + if (mPtr.getTypeName() != typeid(ESM::NPC).name()) + { + MWBase::Environment::get().getWindowManager()-> + messageBox("#{sNotifyMessage9}", std::vector<std::string>()); + return; + } int a = abs(mCurrentMerchantOffer); int b = abs(mCurrentBalance); @@ -202,12 +207,12 @@ namespace MWGui MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); - float a1 = std::min<float>(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); - float b1 = std::min<float>(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); - float c1 = std::min<float>(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); - float d1 = std::min<float>(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); - float e1 = std::min<float>(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); - float f1 = std::min<float>(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + float a1 = std::min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f); + float b1 = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); + float c1 = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); + float d1 = std::min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f); + float e1 = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); + float f1 = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); float pcTerm = (clampedDisposition - 50 + a1 + b1 + c1) * playerStats.getFatigueTerm(); float npcTerm = (d1 + e1 + f1) * sellerStats.getFatigueTerm(); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 240937b7ca..3d49e32c59 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -396,6 +396,9 @@ namespace MWMechanics int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) { + if (ptr.getTypeName() == typeid(ESM::Creature).name()) + return basePrice; + MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(ptr).getCreatureStats(ptr); @@ -419,12 +422,10 @@ namespace MWMechanics float x; if(buying) x = buyTerm; else x = std::min(buyTerm, sellTerm); - //std::cout << "x" << x; int offerPrice; if (x < 1) offerPrice = int(x * basePrice); if (x >= 1) offerPrice = basePrice + int((x - 1) * basePrice); offerPrice = std::max(1, offerPrice); - //std::cout <<"barteroffer"<< offerPrice << " " << basePrice << "\n"; return offerPrice; } } From 322faf13e49bd31f6d6e0ac2e0338d141639f513 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 8 Nov 2012 22:37:59 +0100 Subject: [PATCH 190/255] cleanup --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 3d49e32c59..648b8b6680 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -407,12 +407,12 @@ namespace MWMechanics MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); int clampedDisposition = std::min(disposition(ptr),100); - float a = std::min<float>(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); - float b = std::min<float>(0.1 * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); - float c = std::min<float>(0.2 * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); - float d = std::min<float>(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100); - float e = std::min<float>(0.1 * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10); - float f = std::min<float>(0.2 * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10); + float a = std::min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f); + float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); + float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); + float d = std::min(sellerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f); + float e = std::min(0.1f * sellerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); + float f = std::min(0.2f * sellerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); float pcTerm = (clampedDisposition - 50 + a + b + c) * playerStats.getFatigueTerm(); float npcTerm = (d + e + f) * sellerStats.getFatigueTerm(); From ae78eaeb28f8c746e0771c7be0ed3cab1d735095 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Thu, 8 Nov 2012 23:21:03 +0100 Subject: [PATCH 191/255] fixed training, fixed todo comments --- apps/openmw/mwgui/spellbuyingwindow.cpp | 1 - apps/openmw/mwgui/spellcreationdialog.cpp | 1 - apps/openmw/mwgui/trainingwindow.cpp | 3 +-- apps/openmw/mwgui/travelwindow.cpp | 1 - 4 files changed, 1 insertion(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index b346939b3b..c6e5eb399a 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -68,7 +68,6 @@ namespace MWGui ); mCurrentY += sLineHeight; - /// \todo price adjustment depending on merchantile skill toAdd->setUserData(price); toAdd->setCaptionWithReplacing(spell->mName+" - "+boost::lexical_cast<std::string>(price)+"#{sgp}"); diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 562a48c74f..1d97379362 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -400,7 +400,6 @@ namespace MWGui float fSpellMakingValueMult = store.get<ESM::GameSetting>().find("fSpellMakingValueMult")->getFloat(); - /// \todo mercantile int price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,int(y) * fSpellMakingValueMult,true); mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price))); diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 63bd64721d..81f58fbe1f 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -79,7 +79,6 @@ namespace MWGui for (int i=0; i<3; ++i) { - /// \todo mercantile skill int price = MWBase::Environment::get().getMechanicsManager()->barterOffer (mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true); @@ -121,8 +120,8 @@ namespace MWGui const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); - /// \todo mercantile skill int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt (); + price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); if (mWindowManager.getInventoryWindow()->getPlayerGold()<price) return; diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 338aa68368..4c36b2064b 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -73,7 +73,6 @@ namespace MWGui MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); mCurrentY += sLineHeight; - /// \todo price adjustment depending on merchantile skill if(interior) toAdd->setUserString("interior","y"); else From 39ff2f06ce9567b425070a13e6146f7e2272572f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 9 Nov 2012 14:31:38 +0100 Subject: [PATCH 192/255] added bounty to NpcStats --- apps/openmw/mwmechanics/npcstats.cpp | 12 +++++++++++- apps/openmw/mwmechanics/npcstats.hpp | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index c0da99aaf4..c330cccc8b 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -18,7 +18,7 @@ #include "../mwbase/soundmanager.hpp" MWMechanics::NpcStats::NpcStats() -: mMovementFlags (0), mDrawState (DrawState_Nothing) +: mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0) , mLevelProgress(0) { mSkillIncreases.resize (ESM::Attribute::Length); @@ -238,3 +238,13 @@ bool MWMechanics::NpcStats::hasBeenUsed (const std::string& id) const { return mUsedIds.find (id)!=mUsedIds.end(); } + +int MWMechanics::NpcStats::getBounty() const +{ + return mBounty; +} + +void MWMechanics::NpcStats::setBounty (int bounty) +{ + mBounty = bounty; +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 48e63d7b6e..66f20a676f 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -45,6 +45,7 @@ namespace MWMechanics DrawState_ mDrawState; unsigned int mMovementFlags; Stat<float> mSkill[27]; + int mBounty; int mLevelProgress; // 0-10 @@ -92,6 +93,10 @@ namespace MWMechanics void flagAsUsed (const std::string& id); bool hasBeenUsed (const std::string& id) const; + + int getBounty() const; + + void setBounty (int bounty); }; } From d53a7ade1ec4accbbd087440d24447ee57775098 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 9 Nov 2012 14:42:09 +0100 Subject: [PATCH 193/255] method names, disposition uint->int --- apps/openmw/mwbase/mechanicsmanager.hpp | 4 ++-- apps/openmw/mwgui/dialogue.cpp | 8 ++++---- apps/openmw/mwgui/spellbuyingwindow.cpp | 2 +- apps/openmw/mwgui/spellcreationdialog.cpp | 2 +- apps/openmw/mwgui/tradewindow.cpp | 10 +++++----- apps/openmw/mwgui/trainingwindow.cpp | 4 ++-- apps/openmw/mwgui/travelwindow.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 6 +++--- apps/openmw/mwmechanics/mechanicsmanagerimp.hpp | 4 ++-- apps/openmw/mwmechanics/npcstats.cpp | 4 ++-- apps/openmw/mwmechanics/npcstats.hpp | 6 +++--- 11 files changed, 26 insertions(+), 26 deletions(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 2f29065417..9f9b5af701 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -77,10 +77,10 @@ namespace MWBase virtual void restoreDynamicStats() = 0; ///< If the player is sleeping, this should be called every hour. - virtual int barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0; + virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0; ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. - virtual int disposition(const MWWorld::Ptr& ptr) = 0; + virtual int getDerivedDisposition(const MWWorld::Ptr& ptr) = 0; ///< Calculate the diposition of an NPC toward the player. virtual int countDeaths (const std::string& id) const = 0; diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index 577d1d1100..e1baaf8e00 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -303,9 +303,9 @@ void DialogueWindow::updateOptions() if (mPtr.getTypeName() == typeid(ESM::NPC).name()) { mDispositionBar->setProgressRange(100); - mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); + mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)); mDispositionText->eraseText(0, mDispositionText->getTextLength()); - mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154"); + mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154"); } } @@ -326,8 +326,8 @@ void DialogueWindow::onFrame() if(mEnabled && mPtr.getTypeName() == typeid(ESM::NPC).name()) { mDispositionBar->setProgressRange(100); - mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)); + mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)); mDispositionText->eraseText(0, mDispositionText->getTextLength()); - mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr))+std::string("/100")+"#B29154"); + mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154"); } } diff --git a/apps/openmw/mwgui/spellbuyingwindow.cpp b/apps/openmw/mwgui/spellbuyingwindow.cpp index c6e5eb399a..a41f401a57 100644 --- a/apps/openmw/mwgui/spellbuyingwindow.cpp +++ b/apps/openmw/mwgui/spellbuyingwindow.cpp @@ -55,7 +55,7 @@ namespace MWGui const ESM::Spell* spell = MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId); int price = spell->mData.mCost*store.get<ESM::GameSetting>().find("fSpellValueMult")->getFloat(); - price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); + price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); MyGUI::Button* toAdd = mSpellsView->createWidget<MyGUI::Button>( diff --git a/apps/openmw/mwgui/spellcreationdialog.cpp b/apps/openmw/mwgui/spellcreationdialog.cpp index 1d97379362..69d69519f9 100644 --- a/apps/openmw/mwgui/spellcreationdialog.cpp +++ b/apps/openmw/mwgui/spellcreationdialog.cpp @@ -400,7 +400,7 @@ namespace MWGui float fSpellMakingValueMult = store.get<ESM::GameSetting>().find("fSpellMakingValueMult")->getFloat(); - int price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,int(y) * fSpellMakingValueMult,true); + int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,int(y) * fSpellMakingValueMult,true); mPriceLabel->setCaption(boost::lexical_cast<std::string>(int(price))); diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 3ec0451a29..0707ad985a 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -206,7 +206,7 @@ namespace MWGui if (mCurrentMerchantOffer<0) d = int(100 * (a - b) / a); else d = int(100 * (b - a) / a); - float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->disposition(mPtr)),100)); + float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)),100)); MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(mPtr).getNpcStats(mPtr); MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(mPtr).getCreatureStats(mPtr); @@ -397,16 +397,16 @@ namespace MWGui void TradeWindow::sellToNpc(MWWorld::Ptr item, int count) { - mCurrentBalance -= MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); - mCurrentMerchantOffer -= MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); + mCurrentBalance -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); + mCurrentMerchantOffer -= MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,true); updateLabels(); } void TradeWindow::buyFromNpc(MWWorld::Ptr item, int count) { - mCurrentBalance += MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); - mCurrentMerchantOffer += MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); + mCurrentBalance += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); + mCurrentMerchantOffer += MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr, MWWorld::Class::get(item).getValue(item) * count,false); updateLabels(); } diff --git a/apps/openmw/mwgui/trainingwindow.cpp b/apps/openmw/mwgui/trainingwindow.cpp index 81f58fbe1f..ba39ee601c 100644 --- a/apps/openmw/mwgui/trainingwindow.cpp +++ b/apps/openmw/mwgui/trainingwindow.cpp @@ -79,7 +79,7 @@ namespace MWGui for (int i=0; i<3; ++i) { - int price = MWBase::Environment::get().getMechanicsManager()->barterOffer + int price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer (mPtr,pcStats.getSkill (bestSkills[i].first).getBase() * gmst.find("iTrainingMod")->getInt (),true); std::string skin = (price > mWindowManager.getInventoryWindow ()->getPlayerGold ()) ? "SandTextGreyedOut" : "SandTextButton"; @@ -121,7 +121,7 @@ namespace MWGui MWBase::Environment::get().getWorld()->getStore(); int price = pcStats.getSkill (skillId).getBase() * store.get<ESM::GameSetting>().find("iTrainingMod")->getInt (); - price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); + price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); if (mWindowManager.getInventoryWindow()->getPlayerGold()<price) return; diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 4c36b2064b..abbc6172fe 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -69,7 +69,7 @@ namespace MWGui price = d/gmst.find("fTravelMult")->getFloat(); } - price = MWBase::Environment::get().getMechanicsManager()->barterOffer(mPtr,price,true); + price = MWBase::Environment::get().getMechanicsManager()->getBarterOffer(mPtr,price,true); MyGUI::Button* toAdd = mDestinationsView->createWidget<MyGUI::Button>((price>mWindowManager.getInventoryWindow()->getPlayerGold()) ? "SandTextGreyedOut" : "SandTextButton", 0, mCurrentY, 200, sLineHeight, MyGUI::Align::Default); mCurrentY += sLineHeight; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 897398f08d..3b5a80ef38 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -388,7 +388,7 @@ namespace MWMechanics return lowerCase; } - int MechanicsManager::disposition(const MWWorld::Ptr& ptr) + int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr) { MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); float x = npcSkill.getDisposition(); @@ -448,7 +448,7 @@ namespace MWMechanics return effective_disposition; } - int MechanicsManager::barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) + int MechanicsManager::getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) { if (ptr.getTypeName() == typeid(ESM::Creature).name()) return basePrice; @@ -460,7 +460,7 @@ namespace MWMechanics MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); - int clampedDisposition = std::min(disposition(ptr),100); + int clampedDisposition = std::min(getDerivedDisposition(ptr),100); float a = std::min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f); float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 4f46bd5e32..0344d951cc 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -79,10 +79,10 @@ namespace MWMechanics virtual void restoreDynamicStats(); ///< If the player is sleeping, this should be called every hour. - virtual int barterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying); + virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying); ///< This is used by every service to determine the price of objects given the trading skills of the player and NPC. - virtual int disposition(const MWWorld::Ptr& ptr); + virtual int getDerivedDisposition(const MWWorld::Ptr& ptr); ///< Calculate the diposition of an NPC toward the player. virtual int countDeaths (const std::string& id) const; diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 003d073e74..02e5139edb 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -36,12 +36,12 @@ void MWMechanics::NpcStats::setDrawState (DrawState_ state) mDrawState = state; } -unsigned int MWMechanics::NpcStats::getDisposition() const +int MWMechanics::NpcStats::getDisposition() const { return mDisposition; } -void MWMechanics::NpcStats::setDisposition(unsigned int disposition) +void MWMechanics::NpcStats::setDisposition(int disposition) { mDisposition = disposition; } diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 1fc173f903..893f006484 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -43,7 +43,7 @@ namespace MWMechanics std::map<std::string, int> mFactionRank; DrawState_ mDrawState; - unsigned int mDisposition; + int mDisposition; unsigned int mMovementFlags; Stat<float> mSkill[27]; @@ -61,9 +61,9 @@ namespace MWMechanics void setDrawState (DrawState_ state); - unsigned int getDisposition() const; + int getDisposition() const; - void setDisposition(unsigned int disposition); + void setDisposition(int disposition); bool getMovementFlag (Flag flag) const; From be1334b202d219995869b5d0eedba08c6f2aca22 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 9 Nov 2012 18:16:29 +0100 Subject: [PATCH 194/255] disease tests --- apps/openmw/mwmechanics/creaturestats.cpp | 10 ++++++++ apps/openmw/mwmechanics/creaturestats.hpp | 4 ++++ apps/openmw/mwmechanics/spells.cpp | 28 +++++++++++++++++++++++ apps/openmw/mwmechanics/spells.hpp | 4 ++++ 4 files changed, 46 insertions(+) diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 95e721c01b..e94adf4583 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -232,4 +232,14 @@ namespace MWMechanics mDead = false; } } + + bool CreatureStats::hasCommonDisease() const + { + return mSpells.hasCommonDisease(); + } + + bool CreatureStats::hasBlightDisease() const + { + return mSpells.hasBlightDisease(); + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 671dcd4396..cdeee6853e 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -109,6 +109,10 @@ namespace MWMechanics bool isDead() const; void resurrect(); + + bool hasCommonDisease() const; + + bool hasBlightDisease() const; }; } diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index 3ff10cdb87..ef084f4795 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -75,4 +75,32 @@ namespace MWMechanics { return mSelectedSpell; } + + bool Spells::hasCommonDisease() const + { + for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) + { + const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); + + if (spell->mData.mFlags & ESM::Spell::ST_Disease) + return true; + } + + return false; + } + + bool Spells::hasBlightDisease() const + { + for (TIterator iter = mSpells.begin(); iter!=mSpells.end(); ++iter) + { + const ESM::Spell *spell = + MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find (*iter); + + if (spell->mData.mFlags & ESM::Spell::ST_Blight) + return true; + } + + return false; + } } diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index d90f5b502d..12308661ba 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -55,6 +55,10 @@ namespace MWMechanics const std::string getSelectedSpell() const; ///< May return an empty string. + + bool hasCommonDisease() const; + + bool hasBlightDisease() const; }; } From f6a9029c4b3dec7172d677a22a979d02106f4d53 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 9 Nov 2012 18:33:11 +0100 Subject: [PATCH 195/255] bounty & disease disposition effect --- .../openmw/mwmechanics/mechanicsmanagerimp.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 3b5a80ef38..62b116a47b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -397,7 +397,7 @@ namespace MWMechanics MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::LiveCellRef<ESM::NPC>* player = playerPtr.get<ESM::NPC>(); MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); - MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); + MWMechanics::NpcStats playerNpcStats = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); if (toLower(npc->mBase->mRace) == toLower(player->mBase->mRace)) x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispRaceMod")->getFloat(); @@ -409,21 +409,21 @@ namespace MWMechanics std::string npcFaction = ""; if(!npcSkill.getFactionRanks().empty()) npcFaction = npcSkill.getFactionRanks().begin()->first; - if (playerSkill.getFactionRanks().find(toLower(npcFaction)) != playerSkill.getFactionRanks().end()) + if (playerNpcStats.getFactionRanks().find(toLower(npcFaction)) != playerNpcStats.getFactionRanks().end()) { for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.begin(); it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.end(); it++) { if(toLower(it->mFaction) == toLower(npcFaction)) reaction = it->mReaction; } - rank = playerSkill.getFactionRanks().find(toLower(npcFaction))->second; + rank = playerNpcStats.getFactionRanks().find(toLower(npcFaction))->second; } else if (npcFaction != "") { for(std::vector<ESM::Faction::Reaction>::const_iterator it = MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.begin(); it != MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find(toLower(npcFaction))->mReactions.end();it++) { - if(playerSkill.getFactionRanks().find(toLower(it->mFaction)) != playerSkill.getFactionRanks().end() ) + if(playerNpcStats.getFactionRanks().find(toLower(it->mFaction)) != playerNpcStats.getFactionRanks().end() ) { if(it->mReaction<reaction) reaction = it->mReaction; } @@ -439,10 +439,12 @@ namespace MWMechanics + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispFactionRankBase")->getFloat()) * MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispFactionMod")->getFloat() * reaction; - /// \todo implement bounty and disease - //x -= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispCrimeMod") * pcBounty; - //if (pc has a disease) x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispDiseaseMod"); - if (playerSkill.getDrawState() == MWMechanics::DrawState_::DrawState_Weapon) x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispWeaponDrawn")->getFloat(); + x -= MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispCrimeMod")->getFloat() * playerNpcStats.getBounty(); + if (playerStats.hasCommonDisease() || playerStats.hasBlightDisease()) + x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispDiseaseMod")->getFloat(); + + if (playerNpcStats.getDrawState() == MWMechanics::DrawState_::DrawState_Weapon) + x += MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fDispWeaponDrawn")->getFloat(); int effective_disposition = std::max(0,std::min(int(x),100));//, normally clamped to [0..100] when used return effective_disposition; From ace9ee9c835273686e4b1928335461f89de664f9 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 9 Nov 2012 20:18:38 +0100 Subject: [PATCH 196/255] persuasion dialog --- apps/openmw/mwbase/mechanicsmanager.hpp | 12 ++ apps/openmw/mwclass/npc.cpp | 2 +- apps/openmw/mwgui/dialogue.cpp | 103 ++++++++++++++++++ apps/openmw/mwgui/dialogue.hpp | 32 ++++++ .../mwmechanics/mechanicsmanagerimp.cpp | 8 +- .../mwmechanics/mechanicsmanagerimp.hpp | 2 + apps/openmw/mwmechanics/npcstats.cpp | 4 +- apps/openmw/mwmechanics/npcstats.hpp | 4 +- apps/openmw/mwrender/player.cpp | 3 +- files/mygui/CMakeLists.txt | 1 + 10 files changed, 164 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 9f9b5af701..0be111ea71 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -85,6 +85,18 @@ namespace MWBase virtual int countDeaths (const std::string& id) const = 0; ///< Return the number of deaths for actors with the given ID. + + enum PersuasionType + { + PT_Admire, + PT_Intimidate, + PT_Taunt, + PT_Bribe10, + PT_Bribe100, + PT_Bribe1000 + }; + virtual float getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const = 0; + ///< Get amount to adjust temporary disposition for a given persuasion action on an NPC }; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6a516bcc80..c7f33504ef 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -95,7 +95,7 @@ namespace MWClass data->mCreatureStats.setFatigue (ref->mBase->mNpdt52.mFatigue); data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel); - data->mNpcStats.setDisposition(ref->mBase->mNpdt52.mDisposition); + data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt52.mDisposition); } else { diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index e1baaf8e00..be7bfde53e 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -49,14 +49,87 @@ std::string::size_type find_str_ci(const std::string& str, const std::string& su } + +PersuasionDialog::PersuasionDialog(MWBase::WindowManager &parWindowManager) + : WindowModal("openmw_persuasion_dialog.layout", parWindowManager) +{ + getWidget(mCancelButton, "CancelButton"); + getWidget(mAdmireButton, "AdmireButton"); + getWidget(mIntimidateButton, "IntimidateButton"); + getWidget(mTauntButton, "TauntButton"); + getWidget(mBribe10Button, "Bribe10Button"); + getWidget(mBribe100Button, "Bribe100Button"); + getWidget(mBribe1000Button, "Bribe1000Button"); + getWidget(mGoldLabel, "GoldLabel"); + + mCancelButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onCancel); + mAdmireButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade); + mIntimidateButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade); + mTauntButton->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade); + mBribe10Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade); + mBribe100Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade); + mBribe1000Button->eventMouseButtonClick += MyGUI::newDelegate(this, &PersuasionDialog::onPersuade); +} + +void PersuasionDialog::onCancel(MyGUI::Widget *sender) +{ + setVisible(false); +} + +void PersuasionDialog::onPersuade(MyGUI::Widget *sender) +{ + MWBase::MechanicsManager::PersuasionType type; + if (sender == mAdmireButton) type = MWBase::MechanicsManager::PT_Admire; + else if (sender == mIntimidateButton) type = MWBase::MechanicsManager::PT_Intimidate; + else if (sender == mTauntButton) type = MWBase::MechanicsManager::PT_Taunt; + else if (sender == mBribe10Button) + { + mWindowManager.getTradeWindow()->addOrRemoveGold(-10); + type = MWBase::MechanicsManager::PT_Bribe10; + } + else if (sender == mBribe100Button) + { + mWindowManager.getTradeWindow()->addOrRemoveGold(-100); + type = MWBase::MechanicsManager::PT_Bribe100; + } + else /*if (sender == mBribe1000Button)*/ + { + mWindowManager.getTradeWindow()->addOrRemoveGold(-1000); + type = MWBase::MechanicsManager::PT_Bribe1000; + } + + eventPersuade(type, true, 0); + setVisible(false); +} + +void PersuasionDialog::open() +{ + WindowModal::open(); + center(); + + int playerGold = mWindowManager.getInventoryWindow()->getPlayerGold(); + + mBribe10Button->setEnabled (playerGold >= 10); + mBribe100Button->setEnabled (playerGold >= 100); + mBribe1000Button->setEnabled (playerGold >= 1000); + + mGoldLabel->setCaptionWithReplacing("#{sGold}: " + boost::lexical_cast<std::string>(playerGold)); +} + +// -------------------------------------------------------------------------------------------------- + DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager) : WindowBase("openmw_dialogue_window.layout", parWindowManager) + , mPersuasionDialog(parWindowManager) , mEnabled(false) , mServices(0) { // Centre dialog center(); + mPersuasionDialog.setVisible(false); + mPersuasionDialog.eventPersuade += MyGUI::newDelegate(this, &DialogueWindow::onPersuade); + //History view getWidget(mHistory, "History"); mHistory->setOverflowToTheLeft(true); @@ -137,6 +210,10 @@ void DialogueWindow::onSelectTopic(std::string topic) mWindowManager.pushGuiMode(GM_Barter); mWindowManager.getTradeWindow()->startTrade(mPtr); } + if (topic == gmst.find("sPersuasion")->getString()) + { + mPersuasionDialog.setVisible(true); + } else if (topic == gmst.find("sSpells")->getString()) { mWindowManager.pushGuiMode(GM_SpellBuying); @@ -187,6 +264,9 @@ void DialogueWindow::setKeywords(std::list<std::string> keyWords) const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + if (mPtr.getTypeName() == typeid(ESM::NPC).name()) + mTopicsList->addItem(gmst.find("sPersuasion")->getString()); + if (mServices & Service_Trade) mTopicsList->addItem(gmst.find("sBarter")->getString()); @@ -311,6 +391,8 @@ void DialogueWindow::updateOptions() void DialogueWindow::goodbye() { + // Apply temporary disposition change to NPC's base disposition + mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString()); mTopicsList->setEnabled(false); mEnabled = false; @@ -331,3 +413,24 @@ void DialogueWindow::onFrame() mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154"); } } + +void DialogueWindow::onPersuade(int type, bool success, float dispositionChange) +{ + std::string text; + + if (type == MWBase::MechanicsManager::PT_Admire) + text = "sAdmire"; + else if (type == MWBase::MechanicsManager::PT_Taunt) + text = "sTaunt"; + else if (type == MWBase::MechanicsManager::PT_Intimidate) + text = "sIntimidate"; + else + text = "sBribe"; + + text += success ? "Fail" : "Success"; + + mHistory->addDialogHeading( MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}")); + + /// \todo text from INFO record, how to get the ID? + //mHistory->addDialogText(); +} diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index bb9acf5db9..3d0d74d957 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -26,6 +26,31 @@ namespace MWGui { class DialogueHistory; + class PersuasionDialog : public WindowModal + { + public: + PersuasionDialog(MWBase::WindowManager& parWindowManager); + + virtual void open(); + + typedef MyGUI::delegates::CMultiDelegate3<int, bool, float> EventHandle_Persuade; + + EventHandle_Persuade eventPersuade; + + private: + MyGUI::Button* mCancelButton; + MyGUI::Button* mAdmireButton; + MyGUI::Button* mIntimidateButton; + MyGUI::Button* mTauntButton; + MyGUI::Button* mBribe10Button; + MyGUI::Button* mBribe100Button; + MyGUI::Button* mBribe1000Button; + MyGUI::TextBox* mGoldLabel; + + void onCancel (MyGUI::Widget* sender); + void onPersuade (MyGUI::Widget* sender); + }; + class DialogueWindow: public WindowBase, public ReferenceInterface { public: @@ -86,6 +111,13 @@ namespace MWGui Widgets::MWList* mTopicsList; MyGUI::ProgressPtr mDispositionBar; MyGUI::EditPtr mDispositionText; + + PersuasionDialog mPersuasionDialog; + + + float mTemporaryDispositionChange; + + void onPersuade (int type, bool success, float dispositionChange); }; } #endif diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 62b116a47b..134a7fb06b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -391,7 +391,7 @@ namespace MWMechanics int MechanicsManager::getDerivedDisposition(const MWWorld::Ptr& ptr) { MWMechanics::NpcStats npcSkill = MWWorld::Class::get(ptr).getNpcStats(ptr); - float x = npcSkill.getDisposition(); + float x = npcSkill.getBaseDisposition(); MWWorld::LiveCellRef<ESM::NPC>* npc = ptr.get<ESM::NPC>(); MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); @@ -489,4 +489,10 @@ namespace MWMechanics { return mActors.countDeaths (id); } + + + float MechanicsManager::getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const + { + return 0.f; + } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 0344d951cc..1ec65a8afa 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -88,6 +88,8 @@ namespace MWMechanics virtual int countDeaths (const std::string& id) const; ///< Return the number of deaths for actors with the given ID. + virtual float getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const; + ///< Get amount to adjust temporary disposition for a given persuasion action on an NPC }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 5b2ce739f2..70fd29684b 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -37,12 +37,12 @@ void MWMechanics::NpcStats::setDrawState (DrawState_ state) mDrawState = state; } -int MWMechanics::NpcStats::getDisposition() const +int MWMechanics::NpcStats::getBaseDisposition() const { return mDisposition; } -void MWMechanics::NpcStats::setDisposition(int disposition) +void MWMechanics::NpcStats::setBaseDisposition(int disposition) { mDisposition = disposition; } diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 35af4afa02..3e39eb7f11 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -62,9 +62,9 @@ namespace MWMechanics void setDrawState (DrawState_ state); - int getDisposition() const; + int getBaseDisposition() const; - void setDisposition(int disposition); + void setBaseDisposition(int disposition); bool getMovementFlag (Flag flag) const; diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index bbc75cade1..d0b4641b91 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -23,7 +23,8 @@ namespace MWRender mFreeLook(true), mHeight(128.f), mCameraDistance(300.f), - mDistanceAdjusted(false) + mDistanceAdjusted(false), + mAnimation(NULL) { mVanity.enabled = false; mVanity.allowed = true; diff --git a/files/mygui/CMakeLists.txt b/files/mygui/CMakeLists.txt index da8fba62c0..562668a907 100644 --- a/files/mygui/CMakeLists.txt +++ b/files/mygui/CMakeLists.txt @@ -80,6 +80,7 @@ set(MYGUI_FILES openmw_enchanting_dialog.layout openmw_trainingwindow.layout openmw_travel_window.layout + openmw_persuasion_dialog.layout smallbars.png VeraMono.ttf markers.png From 33b4b29fbc6285d6aea91b23517751cbe3226960 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sat, 10 Nov 2012 00:29:36 +0100 Subject: [PATCH 197/255] persuasion mechanics, added reputation --- apps/openmw/mwbase/dialoguemanager.hpp | 3 + apps/openmw/mwbase/mechanicsmanager.hpp | 5 +- apps/openmw/mwclass/npc.cpp | 1 + apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 57 +++++++ apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 5 + apps/openmw/mwgui/dialogue.cpp | 37 ++--- apps/openmw/mwgui/dialogue.hpp | 11 +- .../mwmechanics/mechanicsmanagerimp.cpp | 146 +++++++++++++++++- .../mwmechanics/mechanicsmanagerimp.hpp | 5 +- apps/openmw/mwmechanics/npcstats.cpp | 12 +- apps/openmw/mwmechanics/npcstats.hpp | 5 + 11 files changed, 245 insertions(+), 42 deletions(-) diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index ccffc6b214..e9854b246d 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -40,6 +40,9 @@ namespace MWBase virtual void keywordSelected (const std::string& keyword) = 0; virtual void goodbyeSelected() = 0; virtual void questionAnswered (const std::string& answer) = 0; + + virtual void persuade (int type) = 0; + virtual int getTemporaryDispositionChange () const = 0; }; } diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 0be111ea71..cdee048dbb 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -95,8 +95,9 @@ namespace MWBase PT_Bribe100, PT_Bribe1000 }; - virtual float getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const = 0; - ///< Get amount to adjust temporary disposition for a given persuasion action on an NPC + virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type, + float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange) = 0; + ///< Perform a persuasion action on NPC }; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index c7f33504ef..790d824f53 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -96,6 +96,7 @@ namespace MWClass data->mCreatureStats.setLevel(ref->mBase->mNpdt52.mLevel); data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt52.mDisposition); + data->mNpcStats.setReputation(ref->mBase->mNpdt52.mReputation); } else { diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 46fab0a4b4..3eabe73836 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -12,6 +12,7 @@ #include "../mwbase/scriptmanager.hpp" #include "../mwbase/journal.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/mechanicsmanager.hpp" #include "../mwworld/class.hpp" #include "../mwworld/refdata.hpp" @@ -584,6 +585,8 @@ namespace MWDialogue DialogueManager::DialogueManager (const Compiler::Extensions& extensions) : mCompilerContext (MWScript::CompilerContext::Type_Dialgoue), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) + , mTemporaryDispositionChange(0.f) + , mPermanentDispositionChange(0.f) { mChoice = -1; mIsInChoice = false; @@ -868,6 +871,12 @@ namespace MWDialogue void DialogueManager::goodbyeSelected() { MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue); + + // Apply disposition change to NPC's base disposition + MWMechanics::NpcStats npcStats = MWWorld::Class::get(mActor).getNpcStats(mActor); + npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange); + mPermanentDispositionChange = 0; + mTemporaryDispositionChange = 0; } void DialogueManager::questionAnswered (const std::string& answer) @@ -944,4 +953,52 @@ namespace MWDialogue win->goodbye(); } + + void DialogueManager::persuade(int type) + { + bool success; + float temp, perm; + MWBase::Environment::get().getMechanicsManager()->getPersuasionDispositionChange( + mActor, MWBase::MechanicsManager::PersuasionType(type), mTemporaryDispositionChange, + success, temp, perm); + mTemporaryDispositionChange += temp; + mPermanentDispositionChange += perm; + + // change temp disposition so that final disposition is between 0...100 + int curDisp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mActor); + if (curDisp + mTemporaryDispositionChange < 0) + mTemporaryDispositionChange = -curDisp; + else if (curDisp + mTemporaryDispositionChange > 100) + mTemporaryDispositionChange = 100 - curDisp; + + // practice skill + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, 0); + + + // add status message to dialogue window + std::string text; + + if (type == MWBase::MechanicsManager::PT_Admire) + text = "sAdmire"; + else if (type == MWBase::MechanicsManager::PT_Taunt) + text = "sTaunt"; + else if (type == MWBase::MechanicsManager::PT_Intimidate) + text = "sIntimidate"; + else + text = "sBribe"; + + text += (success ? "Success" : "Fail"); + + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); + win->addTitle(MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}")); + + /// \todo text from INFO record, how to get the ID? + } + + int DialogueManager::getTemporaryDispositionChange() const + { + return mTemporaryDispositionChange; + } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index e3e9fd7529..d0f48b65a8 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -49,6 +49,9 @@ namespace MWDialogue ESM::DialInfo mLastDialogue; bool mIsInChoice; + float mTemporaryDispositionChange; + float mPermanentDispositionChange; + public: DialogueManager (const Compiler::Extensions& extensions); @@ -69,6 +72,8 @@ namespace MWDialogue virtual void goodbyeSelected(); virtual void questionAnswered (const std::string& answer); + virtual void persuade (int type); + virtual int getTemporaryDispositionChange () const; }; } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index be7bfde53e..d475bc56b5 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -14,6 +14,8 @@ #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" +#include "../mwmechanics/npcstats.hpp" + #include "dialogue_history.hpp" #include "widgets.hpp" #include "list.hpp" @@ -98,7 +100,8 @@ void PersuasionDialog::onPersuade(MyGUI::Widget *sender) type = MWBase::MechanicsManager::PT_Bribe1000; } - eventPersuade(type, true, 0); + MWBase::Environment::get().getDialogueManager()->persuade(type); + setVisible(false); } @@ -128,7 +131,6 @@ DialogueWindow::DialogueWindow(MWBase::WindowManager& parWindowManager) center(); mPersuasionDialog.setVisible(false); - mPersuasionDialog.eventPersuade += MyGUI::newDelegate(this, &DialogueWindow::onPersuade); //History view getWidget(mHistory, "History"); @@ -212,6 +214,7 @@ void DialogueWindow::onSelectTopic(std::string topic) } if (topic == gmst.find("sPersuasion")->getString()) { + mPersuasionDialog.setPtr(mPtr); mPersuasionDialog.setVisible(true); } else if (topic == gmst.find("sSpells")->getString()) @@ -391,8 +394,6 @@ void DialogueWindow::updateOptions() void DialogueWindow::goodbye() { - // Apply temporary disposition change to NPC's base disposition - mHistory->addDialogText("\n#572D21" + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sGoodbye")->getString()); mTopicsList->setEnabled(false); mEnabled = false; @@ -407,30 +408,12 @@ void DialogueWindow::onFrame() { if(mEnabled && mPtr.getTypeName() == typeid(ESM::NPC).name()) { + int disp = std::max(0, std::min(100, + MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr) + + MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange())); mDispositionBar->setProgressRange(100); - mDispositionBar->setProgressPosition(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)); + mDispositionBar->setProgressPosition(disp); mDispositionText->eraseText(0, mDispositionText->getTextLength()); - mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr))+std::string("/100")+"#B29154"); + mDispositionText->addText("#B29154"+boost::lexical_cast<std::string>(disp)+std::string("/100")+"#B29154"); } } - -void DialogueWindow::onPersuade(int type, bool success, float dispositionChange) -{ - std::string text; - - if (type == MWBase::MechanicsManager::PT_Admire) - text = "sAdmire"; - else if (type == MWBase::MechanicsManager::PT_Taunt) - text = "sTaunt"; - else if (type == MWBase::MechanicsManager::PT_Intimidate) - text = "sIntimidate"; - else - text = "sBribe"; - - text += success ? "Fail" : "Success"; - - mHistory->addDialogHeading( MyGUI::LanguageManager::getInstance().replaceTags("#{"+text+"}")); - - /// \todo text from INFO record, how to get the ID? - //mHistory->addDialogText(); -} diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 3d0d74d957..1347922261 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -33,9 +33,7 @@ namespace MWGui virtual void open(); - typedef MyGUI::delegates::CMultiDelegate3<int, bool, float> EventHandle_Persuade; - - EventHandle_Persuade eventPersuade; + void setPtr(MWWorld::Ptr ptr) { mPtr = ptr; } private: MyGUI::Button* mCancelButton; @@ -49,6 +47,8 @@ namespace MWGui void onCancel (MyGUI::Widget* sender); void onPersuade (MyGUI::Widget* sender); + + MWWorld::Ptr mPtr; }; class DialogueWindow: public WindowBase, public ReferenceInterface @@ -113,11 +113,6 @@ namespace MWGui MyGUI::EditPtr mDispositionText; PersuasionDialog mPersuasionDialog; - - - float mTemporaryDispositionChange; - - void onPersuade (int type, bool success, float dispositionChange); }; } #endif diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 134a7fb06b..797369e26b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -491,8 +491,150 @@ namespace MWMechanics } - float MechanicsManager::getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const + void MechanicsManager::getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type, + float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange) { - return 0.f; + const MWWorld::Store<ESM::GameSetting> &gmst = + MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); + + MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); + MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); + + MWMechanics::NpcStats npcSkill = MWWorld::Class::get(npc).getNpcStats(npc); + MWMechanics::CreatureStats npcStats = MWWorld::Class::get(npc).getCreatureStats(npc); + + + float persTerm = playerStats.getAttribute(ESM::Attribute::Personality).getModified() + / gmst.find("fPersonalityMod")->getFloat(); + + float luckTerm = playerStats.getAttribute(ESM::Attribute::Luck).getModified() + / gmst.find("fLuckMod")->getFloat(); + + float repTerm = playerSkill.getReputation() * gmst.find("fReputationMod")->getFloat(); + + float levelTerm = playerStats.getLevel() * gmst.find("fLevelMod")->getFloat(); + + float fatigueTerm = playerStats.getFatigueTerm(); + + float playerRating1 = (repTerm + luckTerm + persTerm + playerSkill.getSkill(ESM::Skill::Speechcraft).getModified()) * fatigueTerm; + float playerRating2 = playerRating1 + levelTerm; + float playerRating3 = (playerSkill.getSkill(ESM::Skill::Mercantile).getModified() + luckTerm + persTerm) * fatigueTerm; + + float npcRating1 = (repTerm + luckTerm + persTerm + playerSkill.getSkill(ESM::Skill::Speechcraft).getModified()) * fatigueTerm; + float npcRating2 = (levelTerm + repTerm + luckTerm + persTerm + npcSkill.getSkill(ESM::Skill::Speechcraft).getModified()) * fatigueTerm; + float npcRating3 = (playerSkill.getSkill(ESM::Skill::Mercantile).getModified() + repTerm + luckTerm + persTerm) * fatigueTerm; + + int currentDisposition = std::min(100, std::max(0, int(getDerivedDisposition(npc) + currentTemporaryDispositionDelta))); + + float d = 1 - 0.02 * abs(currentDisposition - 50); + float target1 = d * (playerRating1 - npcRating1 + 50); + float target2 = d * (playerRating2 - npcRating2 + 50); + + float bribeMod; + if (type == PT_Bribe10) bribeMod = gmst.find("fBribe10Mod")->getFloat(); + if (type == PT_Bribe100) bribeMod = gmst.find("fBribe100Mod")->getFloat(); + else bribeMod = gmst.find("fBribe1000Mod")->getFloat(); + + float target3 = d * (playerRating3 - npcRating3 + 50) + bribeMod; + + float iPerMinChance = gmst.find("iPerMinChance")->getInt(); + float iPerMinChange = gmst.find("iPerMinChange")->getInt(); + float fPerDieRollMult = gmst.find("fPerDieRollMult")->getFloat(); + float fPerTempMult = gmst.find("fPerTempMult")->getFloat(); + + float x,y; + + float roll = static_cast<float> (std::rand()) / RAND_MAX * 100; + + if (type == PT_Admire) + { + target1 = std::max(iPerMinChance, target1); + success = (roll <= target1); + float c = int(fPerDieRollMult * (target1 - roll)); + x = success ? std::max(iPerMinChange, c) : c; + } + else if (type == PT_Intimidate) + { + target2 = std::max(iPerMinChance, target2); + + success = (roll <= target2); + + float r; + if (roll != target2) + r = int(target2 - roll); + else + r = 1; + + if (roll <= target2) + { + float s = int(r * fPerDieRollMult * fPerTempMult); + + npcStats.setFlee ( std::max(0, std::min(100, npcStats.getFlee() + int(std::max(iPerMinChange, s))))); + npcStats.setFight ( std::max(0, std::min(100, npcStats.getFight() + int(std::min(-iPerMinChange, -s))))); + } + + float c = -std::abs(int(r * fPerDieRollMult)); + if (success) + { + if (std::abs(c) < iPerMinChange) + { + x = 0; + y = -iPerMinChange; + } + else + { + x = -int(c * fPerTempMult); + y = c; + } + } + else + { + x = int(c * fPerTempMult); + y = c; + } + } + else if (type == PT_Taunt) + { + target1 = std::max(iPerMinChance, target1); + success = (roll <= target1); + + float c = std::abs(int(target1 - roll)); + + if (roll <= target1) + { + float s = c * fPerDieRollMult * fPerTempMult; + + npcStats.setFlee ( std::max(0, std::min(100, npcStats.getFlee() + std::min(-int(iPerMinChange), int(-s))))); + npcStats.setFight ( std::max(0, std::min(100, npcStats.getFight() + std::max(int(iPerMinChange), int(s))))); + } + x = int(-c * fPerDieRollMult); + + if (success && std::abs(x) < iPerMinChange) + x = -iPerMinChange; + } + else // Bribe + { + target3 = std::max(iPerMinChance, target3); + success = (roll <= target3); + float c = int((target3 - roll) * fPerDieRollMult); + + x = success ? std::max(iPerMinChange, c) : c; + } + + tempChange = type == PT_Intimidate ? x : int(x * fPerTempMult); + + + float cappedDispositionChange = tempChange; + if (currentDisposition + tempChange > 100.f) + cappedDispositionChange = 100 - currentDisposition; + if (currentDisposition + tempChange < 0.f) + cappedDispositionChange = -currentDisposition; + + permChange = int(cappedDispositionChange / fPerTempMult); + if (type == PT_Intimidate) + { + permChange = success ? -int(cappedDispositionChange/ fPerTempMult) : y; + } } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 1ec65a8afa..b03eacecce 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -88,8 +88,9 @@ namespace MWMechanics virtual int countDeaths (const std::string& id) const; ///< Return the number of deaths for actors with the given ID. - virtual float getPersuasionDispositionChange (MWWorld::Ptr npc, PersuasionType type, bool& success) const; - ///< Get amount to adjust temporary disposition for a given persuasion action on an NPC + virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type, + float currentTemporaryDispositionDelta, bool& success, float& tempChange, float& permChange); + ///< Perform a persuasion action on NPC }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 70fd29684b..f37a45b496 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -19,7 +19,7 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0) -, mLevelProgress(0), mDisposition(0) +, mLevelProgress(0), mDisposition(0), mReputation(0) { mSkillIncreases.resize (ESM::Attribute::Length); @@ -259,3 +259,13 @@ void MWMechanics::NpcStats::setBounty (int bounty) { mBounty = bounty; } + +int MWMechanics::NpcStats::getReputation() const +{ + return mReputation; +} + +void MWMechanics::NpcStats::setReputation(int reputation) +{ + mReputation = reputation; +} diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 3e39eb7f11..b6abbd342d 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -47,6 +47,7 @@ namespace MWMechanics unsigned int mMovementFlags; Stat<float> mSkill[27]; int mBounty; + int mReputation; int mLevelProgress; // 0-10 @@ -66,6 +67,10 @@ namespace MWMechanics void setBaseDisposition(int disposition); + int getReputation() const; + + void setReputation(int reputation); + bool getMovementFlag (Flag flag) const; void setMovementFlag (Flag flag, bool state); From 94aeb152202798757e1a246b9e22de953d401454 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sat, 10 Nov 2012 00:38:45 +0100 Subject: [PATCH 198/255] bartering disposition change --- apps/openmw/mwbase/dialoguemanager.hpp | 1 + apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 12 ++++++++++-- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 1 + apps/openmw/mwgui/tradewindow.cpp | 14 +++++++++----- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index e9854b246d..2181ddb588 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -43,6 +43,7 @@ namespace MWBase virtual void persuade (int type) = 0; virtual int getTemporaryDispositionChange () const = 0; + virtual void applyTemporaryDispositionChange (int delta) = 0; }; } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 3eabe73836..60ccda09fe 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -873,8 +873,11 @@ namespace MWDialogue MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue); // Apply disposition change to NPC's base disposition - MWMechanics::NpcStats npcStats = MWWorld::Class::get(mActor).getNpcStats(mActor); - npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange); + if (mActor.getTypeName() == typeid(ESM::NPC).name()) + { + MWMechanics::NpcStats npcStats = MWWorld::Class::get(mActor).getNpcStats(mActor); + npcStats.setBaseDisposition(npcStats.getBaseDisposition() + mPermanentDispositionChange); + } mPermanentDispositionChange = 0; mTemporaryDispositionChange = 0; } @@ -1001,4 +1004,9 @@ namespace MWDialogue { return mTemporaryDispositionChange; } + + void DialogueManager::applyTemporaryDispositionChange(int delta) + { + mTemporaryDispositionChange += delta; + } } diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index d0f48b65a8..a8dea3dbab 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -74,6 +74,7 @@ namespace MWDialogue virtual void persuade (int type); virtual int getTemporaryDispositionChange () const; + virtual void applyTemporaryDispositionChange (int delta); }; } diff --git a/apps/openmw/mwgui/tradewindow.cpp b/apps/openmw/mwgui/tradewindow.cpp index 0707ad985a..c6a21c461f 100644 --- a/apps/openmw/mwgui/tradewindow.cpp +++ b/apps/openmw/mwgui/tradewindow.cpp @@ -7,6 +7,7 @@ #include "../mwbase/soundmanager.hpp" #include "../mwbase/windowmanager.hpp" #include "../mwbase/mechanicsmanager.hpp" +#include "../mwbase/dialoguemanager.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/manualref.hpp" @@ -206,7 +207,8 @@ namespace MWGui if (mCurrentMerchantOffer<0) d = int(100 * (a - b) / a); else d = int(100 * (b - a) / a); - float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr)),100)); + float clampedDisposition = std::max<int>(0,std::min<int>(int(MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(mPtr) + + MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange()),100)); MWMechanics::NpcStats sellerSkill = MWWorld::Class::get(mPtr).getNpcStats(mPtr); MWMechanics::CreatureStats sellerStats = MWWorld::Class::get(mPtr).getCreatureStats(mPtr); @@ -232,13 +234,15 @@ namespace MWGui { MWBase::Environment::get().getWindowManager()-> messageBox("#{sNotifyMessage9}", std::vector<std::string>()); - /// \todo adjust npc temporary disposition by iBarterSuccessDisposition or iBarterFailDisposition - return ; + + int iBarterFailDisposition = gmst.find("iBarterFailDisposition")->getInt(); + MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterFailDisposition); + return; } } - -/// \todo adjust npc temporary disposition by iBarterSuccessDisposition or iBarterFailDisposition + int iBarterSuccessDisposition = gmst.find("iBarterSuccessDisposition")->getInt(); + MWBase::Environment::get().getDialogueManager()->applyTemporaryDispositionChange(iBarterSuccessDisposition); // success! make the item transfer. transferBoughtItems(); From 553ea08eae85562e137d07c4f0597df3dc81a245 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sat, 10 Nov 2012 00:42:31 +0100 Subject: [PATCH 199/255] consider temporary disposition change when trading --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 797369e26b..e0c028b53a 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -6,6 +6,7 @@ #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/windowmanager.hpp" +#include "../mwbase/dialoguemanager.hpp" #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" @@ -462,7 +463,10 @@ namespace MWMechanics MWMechanics::NpcStats playerSkill = MWWorld::Class::get(playerPtr).getNpcStats(playerPtr); MWMechanics::CreatureStats playerStats = MWWorld::Class::get(playerPtr).getCreatureStats(playerPtr); - int clampedDisposition = std::min(getDerivedDisposition(ptr),100); + // I suppose the temporary disposition change _has_ to be considered here, + // otherwise one would get different prices when exiting and re-entering the dialogue window... + int clampedDisposition = std::max(0, std::min(getDerivedDisposition(ptr) + + MWBase::Environment::get().getDialogueManager()->getTemporaryDispositionChange(),100)); float a = std::min(playerSkill.getSkill(ESM::Skill::Mercantile).getModified(), 100.f); float b = std::min(0.1f * playerStats.getAttribute(ESM::Attribute::Luck).getModified(), 10.f); float c = std::min(0.2f * playerStats.getAttribute(ESM::Attribute::Personality).getModified(), 10.f); From 92bba182189de2baacb21312d61cbfb267294f33 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sat, 10 Nov 2012 00:47:24 +0100 Subject: [PATCH 200/255] removed useless member --- apps/openmw/mwgui/dialogue.cpp | 1 - apps/openmw/mwgui/dialogue.hpp | 4 ---- 2 files changed, 5 deletions(-) diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index d475bc56b5..e4c9945b4a 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -214,7 +214,6 @@ void DialogueWindow::onSelectTopic(std::string topic) } if (topic == gmst.find("sPersuasion")->getString()) { - mPersuasionDialog.setPtr(mPtr); mPersuasionDialog.setVisible(true); } else if (topic == gmst.find("sSpells")->getString()) diff --git a/apps/openmw/mwgui/dialogue.hpp b/apps/openmw/mwgui/dialogue.hpp index 1347922261..082d925246 100644 --- a/apps/openmw/mwgui/dialogue.hpp +++ b/apps/openmw/mwgui/dialogue.hpp @@ -33,8 +33,6 @@ namespace MWGui virtual void open(); - void setPtr(MWWorld::Ptr ptr) { mPtr = ptr; } - private: MyGUI::Button* mCancelButton; MyGUI::Button* mAdmireButton; @@ -47,8 +45,6 @@ namespace MWGui void onCancel (MyGUI::Widget* sender); void onPersuade (MyGUI::Widget* sender); - - MWWorld::Ptr mPtr; }; class DialogueWindow: public WindowBase, public ReferenceInterface From b1ef0026a9f64171d28471eb21aac8fc14490318 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sat, 10 Nov 2012 11:41:12 +0400 Subject: [PATCH 201/255] race selection/inventory preview character model update --- apps/openmw/mwbase/mechanicsmanager.hpp | 2 +- apps/openmw/mwgui/charactercreation.cpp | 30 +++++++++++++---- apps/openmw/mwgui/inventorywindow.hpp | 4 +++ apps/openmw/mwgui/race.cpp | 23 +++++++++++++ apps/openmw/mwgui/race.hpp | 1 + .../mwmechanics/mechanicsmanagerimp.cpp | 10 +++--- .../mwmechanics/mechanicsmanagerimp.hpp | 2 +- apps/openmw/mwrender/characterpreview.cpp | 32 +++++++++++++++++-- apps/openmw/mwrender/characterpreview.hpp | 11 +++++++ components/esm/loadnpc.hpp | 7 ++++ 10 files changed, 104 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 750fc2fff8..e1a83c747d 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -62,7 +62,7 @@ namespace MWBase virtual void setPlayerName (const std::string& name) = 0; ///< Set player name. - virtual void setPlayerRace (const std::string& id, bool male) = 0; + virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair) = 0; ///< Set player race. virtual void setPlayerBirthsign (const std::string& id) = 0; diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index a054f34ddd..4778460551 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -7,6 +7,7 @@ #include "review.hpp" #include "dialogue.hpp" #include "mode.hpp" +#include "inventorywindow.hpp" #include "../mwbase/environment.hpp" #include "../mwbase/soundmanager.hpp" @@ -459,9 +460,16 @@ void CharacterCreation::onRaceDialogBack() { if (mRaceDialog) { - mPlayerRaceId = mRaceDialog->getRaceId(); - if (!mPlayerRaceId.empty()) - MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); + const ESM::NPC &data = mRaceDialog->getResult(); + mPlayerRaceId = data.mId; + if (!mPlayerRaceId.empty()) { + MWBase::Environment::get().getMechanicsManager()->setPlayerRace( + data.mId, + data.isMale(), + data.mHead, + data.mHair + ); + } mWM->removeDialog(mRaceDialog); mRaceDialog = 0; } @@ -474,10 +482,18 @@ void CharacterCreation::onRaceDialogDone(WindowBase* parWindow) { if (mRaceDialog) { - mPlayerRaceId = mRaceDialog->getRaceId(); - mWM->setValue("race", mPlayerRaceId); - if (!mPlayerRaceId.empty()) - MWBase::Environment::get().getMechanicsManager()->setPlayerRace(mPlayerRaceId, mRaceDialog->getGender() == RaceDialog::GM_Male); + const ESM::NPC &data = mRaceDialog->getResult(); + mPlayerRaceId = data.mRace; + if (!mPlayerRaceId.empty()) { + MWBase::Environment::get().getMechanicsManager()->setPlayerRace( + data.mRace, + data.isMale(), + data.mHead, + data.mHair + ); + } + mWM->getInventoryWindow()->rebuildAvatar(); + mWM->removeDialog(mRaceDialog); mRaceDialog = 0; } diff --git a/apps/openmw/mwgui/inventorywindow.hpp b/apps/openmw/mwgui/inventorywindow.hpp index 84b576a58c..6b45a99800 100644 --- a/apps/openmw/mwgui/inventorywindow.hpp +++ b/apps/openmw/mwgui/inventorywindow.hpp @@ -28,6 +28,10 @@ namespace MWGui MWWorld::Ptr getAvatarSelectedItem(int x, int y); + void rebuildAvatar() { + mPreview.rebuild(); + } + protected: MyGUI::Widget* mAvatar; MyGUI::ImageBox* mAvatarImage; diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 943081e65e..ff7c01ade6 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -214,6 +214,29 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) return; mCurrentRaceId = *raceId; + + ESM::NPC record = mPreview->getPrototype(); + record.mRace = mCurrentRaceId; + record.setIsMale(mGenderIndex == 0); + + std::string prefix = + "b_n_" + mCurrentRaceId + ((record.isMale()) ? "_m_" : "_f_"); + + record.mHead = prefix + "head_01"; + record.mHair = prefix + "hair_01"; + + const MWWorld::Store<ESM::BodyPart> &parts = + MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); + + if (parts.search(record.mHair) == 0) { + record.mHair = prefix + "hair01"; + } + + mFaceIndex = 0; + mHairIndex = 0; + + mPreview->setPrototype(record); + updateSkills(); updateSpellPowers(); } diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index 000b845231..ec73d1c3a4 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -34,6 +34,7 @@ namespace MWGui GM_Female }; + const ESM::NPC &getResult() const { return mPreview->getPrototype(); } const std::string &getRaceId() const { return mCurrentRaceId; } Gender getGender() const { return mGenderIndex == 0 ? GM_Male : GM_Female; } // getFace() diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 50868eeb35..aecde12527 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -318,7 +318,7 @@ namespace MWMechanics mUpdatePlayer = true; } - void MechanicsManager::setPlayerRace (const std::string& race, bool male) + void MechanicsManager::setPlayerRace (const std::string& race, bool male, const std::string &head, const std::string &hair) { MWBase::World *world = MWBase::Environment::get().getWorld(); @@ -326,11 +326,9 @@ namespace MWMechanics *world->getPlayer().getPlayer().get<ESM::NPC>()->mBase; player.mRace = race; - - player.mFlags |= ESM::NPC::Female; - if (male) { - player.mFlags ^= ESM::NPC::Female; - } + player.mHead = head; + player.mHair = hair; + player.setIsMale(male); world->createRecord(player); diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 38536d3bd7..79a45821ad 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -64,7 +64,7 @@ namespace MWMechanics virtual void setPlayerName (const std::string& name); ///< Set player name. - virtual void setPlayerRace (const std::string& id, bool male); + virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair); ///< Set player race. virtual void setPlayerBirthsign (const std::string& id); diff --git a/apps/openmw/mwrender/characterpreview.cpp b/apps/openmw/mwrender/characterpreview.cpp index 017062baa2..0a11dc2814 100644 --- a/apps/openmw/mwrender/characterpreview.cpp +++ b/apps/openmw/mwrender/characterpreview.cpp @@ -48,8 +48,9 @@ namespace MWRender mNode->setVisible (false); - mCamera->setPosition(mPosition); - mCamera->lookAt(mLookAt); + Ogre::Vector3 scale = mNode->getScale(); + mCamera->setPosition(mPosition * scale); + mCamera->lookAt(mLookAt * scale); mCamera->setNearClipDistance (0.01); mCamera->setFarClipDistance (1000); @@ -80,6 +81,22 @@ namespace MWRender delete mAnimation; } + void CharacterPreview::rebuild() + { + assert(mAnimation); + delete mAnimation; + + mAnimation = new NpcAnimation(mCharacter, mNode, + MWWorld::Class::get(mCharacter).getInventoryStore (mCharacter), RV_PlayerPreview); + + mNode->setVisible (false); + + Ogre::Vector3 scale = mNode->getScale(); + mCamera->setPosition(mPosition * scale); + mCamera->lookAt(mLookAt * scale); + + onSetup(); + } // -------------------------------------------------------------------------------------------------- @@ -128,8 +145,10 @@ namespace MWRender RaceSelectionPreview::RaceSelectionPreview() : CharacterPreview(MWBase::Environment::get().getWorld()->getPlayer().getPlayer(), 512, 512, "CharacterHeadPreview", Ogre::Vector3(0, 120, -35), Ogre::Vector3(0,125,0)) + , mRef(&mBase) { - + mBase = *mCharacter.get<ESM::NPC>()->mBase; + mCharacter = MWWorld::Ptr(&mRef, mCharacter.getCell()); } void RaceSelectionPreview::update(float angle) @@ -141,4 +160,11 @@ namespace MWRender mNode->setVisible (false); } + void RaceSelectionPreview::setPrototype(const ESM::NPC &proto) + { + mBase = proto; + mBase.mId = "player"; + rebuild(); + update(0); + } } diff --git a/apps/openmw/mwrender/characterpreview.hpp b/apps/openmw/mwrender/characterpreview.hpp index 2a6b12b9ec..18362d1db6 100644 --- a/apps/openmw/mwrender/characterpreview.hpp +++ b/apps/openmw/mwrender/characterpreview.hpp @@ -4,6 +4,7 @@ #include <OgreRenderTarget.h> #include <OgreMaterialManager.h> +#include <components/esm/loadnpc.hpp> #include "externalrendering.hpp" @@ -32,6 +33,7 @@ namespace MWRender virtual void setup (Ogre::SceneManager *sceneManager); virtual void onSetup(); + virtual void rebuild(); protected: Ogre::TexturePtr mTexture; @@ -77,10 +79,19 @@ namespace MWRender class RaceSelectionPreview : public CharacterPreview { + ESM::NPC mBase; + MWWorld::LiveCellRef<ESM::NPC> mRef; + public: RaceSelectionPreview(); void update(float angle); + + const ESM::NPC &getPrototype() const { + return mBase; + } + + void setPrototype(const ESM::NPC &proto); }; } diff --git a/components/esm/loadnpc.hpp b/components/esm/loadnpc.hpp index d446ee08fb..46be29961d 100644 --- a/components/esm/loadnpc.hpp +++ b/components/esm/loadnpc.hpp @@ -121,6 +121,13 @@ struct NPC bool isMale() const { return (mFlags & Female) == 0; } + + void setIsMale(bool value) { + mFlags |= Female; + if (value) { + mFlags ^= Female; + } + } }; } #endif From 235b565bb7c8c2ebe8500d5c72819ba46306863d Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sat, 10 Nov 2012 11:51:48 +0400 Subject: [PATCH 202/255] update main character model --- apps/openmw/mwrender/player.cpp | 3 +++ apps/openmw/mwworld/worldimp.cpp | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index f2c313e140..8578788118 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -310,6 +310,9 @@ namespace MWRender void Player::setAnimation(NpcAnimation *anim) { + if (mAnimation) { + delete mAnimation; + } mAnimation = anim; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index af5745744b..616a0be39d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -801,7 +801,21 @@ namespace MWWorld const ESM::NPC *World::createRecord(const ESM::NPC &record) { - return mStore.insert(record); + bool update = false; + if (StringUtils::ciEqual(record.mId, "player")) { + const ESM::NPC *player = + mPlayer->getPlayer().get<ESM::NPC>()->mBase; + + update = record.isMale() != player->isMale() || + !StringUtils::ciEqual(record.mRace, player->mRace) || + !StringUtils::ciEqual(record.mHead, player->mHead) || + !StringUtils::ciEqual(record.mHair, player->mHair); + } + const ESM::NPC *ret = mStore.insert(record); + if (update) { + mRendering->renderPlayer(mPlayer->getPlayer()); + } + return ret; } void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode, From a752536ceac31dbb72352f058ee2119867f5fc2b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 09:35:50 +0100 Subject: [PATCH 203/255] Issue #219: added function decoding and moved same faction function from DialogueManager to Filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 19 ------------------- apps/openmw/mwdialogue/filter.cpp | 8 ++++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 13 +++++++++++++ apps/openmw/mwdialogue/selectwrapper.hpp | 9 +++++++-- apps/openmw/mwmechanics/npcstats.cpp | 10 ++++++++++ apps/openmw/mwmechanics/npcstats.hpp | 3 +++ 6 files changed, 41 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 15852198f7..74ee44aa9b 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -97,8 +97,6 @@ namespace MWDialogue bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice) { - bool isCreature = (actor.getTypeName() != typeid(ESM::NPC).name()); - for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.mSelects.begin()); iter != info.mSelects.end(); ++iter) { @@ -131,23 +129,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 46://Same faction - { - if (isCreature) - return false; - - MWMechanics::NpcStats PCstats = MWWorld::Class::get(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()).getNpcStats(MWBase::Environment::get().getWorld()->getPlayer().getPlayer()); - MWMechanics::NpcStats NPCstats = MWWorld::Class::get(actor).getNpcStats(actor); - int sameFaction = 0; - if(!NPCstats.getFactionRanks().empty()) - { - std::string NPCFaction = NPCstats.getFactionRanks().begin()->first; - if(PCstats.getFactionRanks().find(toLower(NPCFaction)) != PCstats.getFactionRanks().end()) sameFaction = 1; - } - if(!selectCompare<int,int>(comp,sameFaction,select.mI)) return false; - } - break; - case 48://Detected if(!selectCompare<int,int>(comp,1,select.mI)) return false; break; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 4ad7bc1578..1e03864bae 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -250,6 +250,14 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return toLower (mActor.getCell()->mCell->mName)==select.getName(); + case SelectWrapper::Function_SameFaction: + { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + return MWWorld::Class::get (mActor).getNpcStats (mActor).isSameFaction ( + MWWorld::Class::get (player).getNpcStats (player)); + } + default: throw std::runtime_error ("unknown boolean select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index effb431108..1ffdd208cd 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -5,6 +5,7 @@ #include <stdexcept> #include <algorithm> +#include <sstream> namespace { @@ -52,6 +53,15 @@ namespace } } +MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() const +{ + int index = 0; + + std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index; + + return static_cast<Function> (index); +} + MWDialogue::SelectWrapper::SelectWrapper (const ESM::DialInfo::SelectStruct& select) : mSelect (select) {} MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() const @@ -60,6 +70,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con switch (type) { + case '1': return decodeFunction(); case '2': return Function_Global; case '3': return Function_Local; case '4': return Function_Journal; @@ -93,6 +104,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const static const Function booleanFunctions[] = { Function_Id, Function_Faction, Function_Class, Function_Race, Function_Cell, + Function_SameFaction, Function_None // end marker }; @@ -125,6 +137,7 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const static const Function functions[] = { Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race, + Function_SameFaction, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 1bd528be05..052f738376 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -13,7 +13,7 @@ namespace MWDialogue enum Function { - Function_None, + Function_None = 0, Function_Journal, Function_Item, Function_Dead, @@ -23,7 +23,8 @@ namespace MWDialogue Function_Race, Function_Cell, Function_Local, - Function_Global + Function_Global, + Function_SameFaction }; enum Type @@ -33,6 +34,10 @@ namespace MWDialogue Type_Numeric, Type_Boolean }; + + private: + + Function decodeFunction() const; public: diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 5b2ce739f2..cc054c1dcd 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -86,6 +86,16 @@ const std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks() const return mFactionRank; } +bool MWMechanics::NpcStats::isSameFaction (const NpcStats& npcStats) const +{ + for (std::map<std::string, int>::const_iterator iter (mFactionRank.begin()); iter!=mFactionRank.end(); + ++iter) + if (npcStats.mFactionRank.find (iter->first)!=npcStats.mFactionRank.end()) + return true; + + return false; +} + float MWMechanics::NpcStats::getSkillGain (int skillIndex, const ESM::Class& class_, int usageType, int level) const { diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 35af4afa02..a6f7adaf11 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -76,6 +76,9 @@ namespace MWMechanics std::map<std::string, int>& getFactionRanks(); + bool isSameFaction (const NpcStats& npcStats) const; + ///< Do *this and \a npcStats share a faction? + const std::map<std::string, int>& getFactionRanks() const; float getSkillGain (int skillIndex, const ESM::Class& class_, int usageType = -1, From c425b3f4a35494017b74b981c0755ec41b5120fa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 09:48:20 +0100 Subject: [PATCH 204/255] Issue #219: fixed function decoding and moved choice function from DialogueManager to Filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 15 ++++----------- apps/openmw/mwdialogue/filter.cpp | 6 +++++- apps/openmw/mwdialogue/filter.hpp | 3 ++- apps/openmw/mwdialogue/selectwrapper.cpp | 9 ++++++++- apps/openmw/mwdialogue/selectwrapper.hpp | 5 +++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 74ee44aa9b..d5af289644 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -137,13 +137,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 50://choice - if(choice) - { - if(!selectCompare<int,int>(comp,mChoice,select.mI)) return false; - } - break; - case 60://PC Vampire if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; @@ -287,7 +280,7 @@ namespace MWDialogue const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); - Filter filter (actor); + Filter filter (actor, mChoice); MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) @@ -391,7 +384,7 @@ namespace MWDialogue const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); - Filter filter (mActor); + Filter filter (mActor, mChoice); MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) @@ -478,7 +471,7 @@ namespace MWDialogue ESM::Dialogue ndialogue = mDialogueMap[keyword]; if(ndialogue.mType == ESM::Dialogue::Topic) { - Filter filter (mActor); + Filter filter (mActor, mChoice); for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) @@ -525,7 +518,7 @@ namespace MWDialogue ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; if(ndialogue.mType == ESM::Dialogue::Topic) { - Filter filter (mActor); + Filter filter (mActor, mChoice); for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 1e03864bae..59027617ff 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -220,6 +220,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return MWBase::Environment::get().getMechanicsManager()->countDeaths (select.getName()); + case SelectWrapper::Function_Choice: + + return mChoice; + default: throw std::runtime_error ("unknown integer select function"); @@ -264,7 +268,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co } } -MWDialogue::Filter::Filter (const MWWorld::Ptr& actor) : mActor (actor) {} +MWDialogue::Filter::Filter (const MWWorld::Ptr& actor, int choice) : mActor (actor), mChoice (choice) {} bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const { diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index 4263920cb2..a849dc0167 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -15,6 +15,7 @@ namespace MWDialogue class Filter { MWWorld::Ptr mActor; + int mChoice; bool testActor (const ESM::DialInfo& info) const; ///< Is this the right actor for this \a info? @@ -35,7 +36,7 @@ namespace MWDialogue public: - Filter (const MWWorld::Ptr& actor); + Filter (const MWWorld::Ptr& actor, int choice); bool operator() (const ESM::DialInfo& info) const; ///< \return does the dialogue match? diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 1ffdd208cd..bfd7f8cf8c 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -59,7 +59,13 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index; - return static_cast<Function> (index); + switch (index) + { + case 46: return Function_SameFaction; + case 50: return Function_Choice; + } + + return Function_None; } MWDialogue::SelectWrapper::SelectWrapper (const ESM::DialInfo::SelectStruct& select) : mSelect (select) {} @@ -92,6 +98,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const static const Function integerFunctions[] = { Function_Journal, Function_Item, Function_Dead, + Function_Choice, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 052f738376..4f105aa5a5 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -13,7 +13,7 @@ namespace MWDialogue enum Function { - Function_None = 0, + Function_None, Function_Journal, Function_Item, Function_Dead, @@ -24,7 +24,8 @@ namespace MWDialogue Function_Cell, Function_Local, Function_Global, - Function_SameFaction + Function_SameFaction, + Function_Choice }; enum Type From eb4e72aaa7b626b3310f0741b32a435affeea488 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 11:08:36 +0100 Subject: [PATCH 205/255] Issue #219: implemented disease filters --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 8 ------- apps/openmw/mwdialogue/filter.cpp | 22 +++++++++++++++---- apps/openmw/mwdialogue/selectwrapper.cpp | 4 ++++ apps/openmw/mwdialogue/selectwrapper.hpp | 3 ++- 4 files changed, 24 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index d5af289644..dcba11c170 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -117,14 +117,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 40://PC Common Disease - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 41://PC Blight Disease - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 43://PC Crime level if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 59027617ff..5a1ec2d84e 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -11,6 +11,8 @@ #include "../mwworld/containerstore.hpp" #include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/creaturestats.hpp" +#include "../mwmechanics/magiceffects.hpp" #include "selectwrapper.hpp" @@ -232,6 +234,8 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) const { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + switch (select.getFunction()) { case SelectWrapper::Function_Id: @@ -255,12 +259,22 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return toLower (mActor.getCell()->mCell->mName)==select.getName(); case SelectWrapper::Function_SameFaction: - { - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - + return MWWorld::Class::get (mActor).getNpcStats (mActor).isSameFaction ( MWWorld::Class::get (player).getNpcStats (player)); - } + + case SelectWrapper::Function_PcCommonDisease: + + return MWWorld::Class::get (player).getCreatureStats (player).hasCommonDisease(); + + case SelectWrapper::Function_PcBlightDisease: + + return MWWorld::Class::get (player).getCreatureStats (player).hasBlightDisease(); + + case SelectWrapper::Function_PcCorprus: + + return MWWorld::Class::get (player).getCreatureStats (player). + getMagicEffects().get (132).mMagnitude!=0; default: diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index bfd7f8cf8c..d49d73a8d8 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -61,8 +61,11 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() switch (index) { + case 40: return Function_PcCommonDisease; + case 41: return Function_PcBlightDisease; case 46: return Function_SameFaction; case 50: return Function_Choice; + case 58: return Function_PcCorprus; } return Function_None; @@ -112,6 +115,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const { Function_Id, Function_Faction, Function_Class, Function_Race, Function_Cell, Function_SameFaction, + Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 4f105aa5a5..d0e2dbb6a6 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -25,7 +25,8 @@ namespace MWDialogue Function_Local, Function_Global, Function_SameFaction, - Function_Choice + Function_Choice, + Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus }; enum Type From ceaf1677ce3738af74d42d99f7c38d9f487a3f9e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 11:38:37 +0100 Subject: [PATCH 206/255] Issue #219: rewrote AI settings and implemented AI settings filters --- apps/openmw/mwclass/creature.cpp | 8 +-- apps/openmw/mwclass/npc.cpp | 8 +-- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 18 +------ apps/openmw/mwdialogue/filter.cpp | 9 +++- apps/openmw/mwdialogue/selectwrapper.cpp | 23 +++++++++ apps/openmw/mwdialogue/selectwrapper.hpp | 5 +- apps/openmw/mwmechanics/creaturestats.cpp | 50 +++++-------------- apps/openmw/mwmechanics/creaturestats.hpp | 25 +++------- apps/openmw/mwscript/aiextensions.cpp | 8 +-- 9 files changed, 65 insertions(+), 89 deletions(-) diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 910838e121..edf5dd25d6 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -62,10 +62,10 @@ namespace MWClass data->mCreatureStats.setLevel(ref->mBase->mData.mLevel); - data->mCreatureStats.setHello(ref->mBase->mAiData.mHello); - data->mCreatureStats.setFight(ref->mBase->mAiData.mFight); - data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee); - data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm); + data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello); + data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight); + data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee); + data->mCreatureStats.setAiSetting (3, ref->mBase->mAiData.mAlarm); // spells for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin()); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 6a516bcc80..f95fbd116f 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -109,10 +109,10 @@ namespace MWClass data->mCreatureStats.setLevel (1); } - data->mCreatureStats.setHello(ref->mBase->mAiData.mHello); - data->mCreatureStats.setFight(ref->mBase->mAiData.mFight); - data->mCreatureStats.setFlee(ref->mBase->mAiData.mFlee); - data->mCreatureStats.setAlarm(ref->mBase->mAiData.mAlarm); + data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello); + data->mCreatureStats.setAiSetting (1, ref->mBase->mAiData.mFight); + data->mCreatureStats.setAiSetting (2, ref->mBase->mAiData.mFlee); + data->mCreatureStats.setAiSetting (3, ref->mBase->mAiData.mAlarm); // spells for (std::vector<std::string>::const_iterator iter (ref->mBase->mSpells.mList.begin()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index dcba11c170..4cc3daf3f0 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -157,22 +157,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 67://Fight - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 68://Hello???? - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 69://Alarm - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 70://Flee - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 71://Should Attack if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; @@ -184,7 +168,7 @@ namespace MWDialogue } } - return true; + return false; } bool DialogueManager::isMatching (const MWWorld::Ptr& actor, diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 5a1ec2d84e..6ef13a9fa2 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -196,6 +196,8 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) const { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + switch (select.getFunction()) { case SelectWrapper::Function_Journal: @@ -204,7 +206,6 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con case SelectWrapper::Function_Item: { - MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); int sum = 0; @@ -226,6 +227,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return mChoice; + case SelectWrapper::Function_AiSetting: + + return MWWorld::Class::get (player).getCreatureStats (player).getAiSetting (select.getArgument()); + default: throw std::runtime_error ("unknown integer select function"); @@ -235,7 +240,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) const { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - + switch (select.getFunction()) { case SelectWrapper::Function_Id: diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index d49d73a8d8..42626fd49c 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -66,6 +66,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 46: return Function_SameFaction; case 50: return Function_Choice; case 58: return Function_PcCorprus; + case 67: case 68: case 69: case 70: return Function_AiSetting; } return Function_None; @@ -96,12 +97,34 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::getFunction() con return Function_None; } +int MWDialogue::SelectWrapper::getArgument() const +{ + if (mSelect.mSelectRule[1]!='1') + return 0; + + int index = 0; + + std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index; + + switch (index) + { + // AI settings + case 67: return 1; + case 68: return 0; + case 69: return 3; + case 70: return 2; + } + + return 0; +} + MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const { static const Function integerFunctions[] = { Function_Journal, Function_Item, Function_Dead, Function_Choice, + Function_AiSetting, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index d0e2dbb6a6..ee5d29cca4 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -26,7 +26,8 @@ namespace MWDialogue Function_Global, Function_SameFaction, Function_Choice, - Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus + Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, + Function_AiSetting }; enum Type @@ -47,6 +48,8 @@ namespace MWDialogue Function getFunction() const; + int getArgument() const; + Type getType() const; bool isInverted() const; diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index e94adf4583..10b9b2f7e4 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -10,8 +10,10 @@ namespace MWMechanics { CreatureStats::CreatureStats() - : mLevel (0), mHello (0), mFight (0), mFlee (0), mAlarm (0), mLevelHealthBonus(0.f), mDead (false) + : mLevel (0), mLevelHealthBonus(0.f), mDead (false) { + for (int i=0; i<4; ++i) + mAiSettings[i] = 0; } void CreatureStats::increaseLevelHealthBonus (float value) @@ -90,27 +92,13 @@ namespace MWMechanics { return mLevel; } + + int CreatureStats::getAiSetting (int index) const + { + assert (index>=0 && index<4); + return mAiSettings[index]; + } - int CreatureStats::getHello() const - { - return mHello; - } - - int CreatureStats::getFight() const - { - return mFight; - } - - int CreatureStats::getFlee() const - { - return mFlee; - } - - int CreatureStats::getAlarm() const - { - return mAlarm; - } - Stat<int> &CreatureStats::getAttribute(int index) { if (index < 0 || index > 7) { @@ -196,25 +184,11 @@ namespace MWMechanics mMagicEffects = effects; } - void CreatureStats::setHello(int value) + void CreatureStats::setAiSetting (int index, int value) { - mHello = value; + assert (index>=0 && index<4); + mAiSettings[index] = value; } - - void CreatureStats::setFight(int value) - { - mFight = value; - } - - void CreatureStats::setFlee(int value) - { - mFlee = value; - } - - void CreatureStats::setAlarm(int value) - { - mAlarm = value; - } bool CreatureStats::isDead() const { diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index cdeee6853e..bbb8b8b300 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -24,10 +24,7 @@ namespace MWMechanics Spells mSpells; ActiveSpells mActiveSpells; MagicEffects mMagicEffects; - int mHello; - int mFight; - int mFlee; - int mAlarm; + int mAiSettings[4]; AiSequence mAiSequence; float mLevelHealthBonus; bool mDead; @@ -53,13 +50,8 @@ namespace MWMechanics int getLevel() const; - int getHello() const; - - int getFight() const; - - int getFlee() const; - - int getAlarm() const; + int getAiSetting (int index) const; + ///< 0: hello, 1 fight, 2 flee, 3 alarm Stat<int> & getAttribute(int index); @@ -87,14 +79,9 @@ namespace MWMechanics void setLevel(int level); - void setHello(int value); - - void setFight(int value); - - void setFlee(int value); - - void setAlarm(int value); - + void setAiSetting (int index, int value); + ///< 0: hello, 1 fight, 2 flee, 3 alarm + const AiSequence& getAiSequence() const; AiSequence& getAiSequence(); diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 9d70c28bd7..787962ad1e 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -130,7 +130,7 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getCreatureStats (ptr).setHello(value); + MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (0, value); } }; @@ -146,7 +146,7 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getCreatureStats (ptr).setFight(value); + MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (1, value); } }; @@ -162,7 +162,7 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getCreatureStats (ptr).setFlee(value); + MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (2, value); } }; @@ -178,7 +178,7 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWWorld::Class::get (ptr).getCreatureStats (ptr).setAlarm(value); + MWWorld::Class::get (ptr).getCreatureStats (ptr).setAiSetting (3, value); } }; From d6961c024628c5d9c706e0842306a27846dc754f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 11:42:03 +0100 Subject: [PATCH 207/255] Issue #219: made all unimplemented filters return false --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 2 +- apps/openmw/mwdialogue/filter.cpp | 4 ++++ apps/openmw/mwdialogue/selectwrapper.cpp | 3 ++- apps/openmw/mwdialogue/selectwrapper.hpp | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 4cc3daf3f0..a9e5640782 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -168,7 +168,7 @@ namespace MWDialogue } } - return false; + return true; } bool DialogueManager::isMatching (const MWWorld::Ptr& actor, diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 6ef13a9fa2..10bcfd8aad 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -243,6 +243,10 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co switch (select.getFunction()) { + case SelectWrapper::Function_False: + + return false; + case SelectWrapper::Function_Id: return select.getName()==toLower (MWWorld::Class::get (mActor).getId (mActor)); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 42626fd49c..d70e88e8b9 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -69,7 +69,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 67: case 68: case 69: case 70: return Function_AiSetting; } - return Function_None; + return Function_False; } MWDialogue::SelectWrapper::SelectWrapper (const ESM::DialInfo::SelectStruct& select) : mSelect (select) {} @@ -136,6 +136,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const static const Function booleanFunctions[] = { + Function_False, Function_Id, Function_Faction, Function_Class, Function_Race, Function_Cell, Function_SameFaction, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index ee5d29cca4..3ff55eb614 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -13,7 +13,7 @@ namespace MWDialogue enum Function { - Function_None, + Function_None, Function_False, Function_Journal, Function_Item, Function_Dead, From bd2c772daefa29d879a3d665ed878b4ad0edd9fe Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 12:08:04 +0100 Subject: [PATCH 208/255] Issue #219: implemented player skill and attribute filter --- apps/openmw/mwdialogue/filter.cpp | 10 +++++ apps/openmw/mwdialogue/selectwrapper.cpp | 53 +++++++++++++++++++++++- apps/openmw/mwdialogue/selectwrapper.hpp | 3 +- 3 files changed, 64 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 10bcfd8aad..4000d3150d 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -231,6 +231,16 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return MWWorld::Class::get (player).getCreatureStats (player).getAiSetting (select.getArgument()); + case SelectWrapper::Function_PcAttribute: + + return MWWorld::Class::get (player).getCreatureStats (player). + getAttribute (select.getArgument()).getModified(); + + case SelectWrapper::Function_PcSkill: + + return static_cast<int> (MWWorld::Class::get (player). + getNpcStats (player).getSkill (select.getArgument()).getModified()); + default: throw std::runtime_error ("unknown integer select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index d70e88e8b9..6b604c1aae 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -58,15 +58,26 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() int index = 0; std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index; - + switch (index) { + // 0-9 + case 10: return Function_PcAttribute; + case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: + case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: + case 31: case 32: case 33: case 34: case 35: case 36: case 37: return Function_PcSkill; + // 38, 39 case 40: return Function_PcCommonDisease; case 41: return Function_PcBlightDisease; + // 42-45 case 46: return Function_SameFaction; + // 47-49 case 50: return Function_Choice; + case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute; case 58: return Function_PcCorprus; + // 59-66 case 67: case 68: case 69: case 70: return Function_AiSetting; + // 71-77 } return Function_False; @@ -113,6 +124,45 @@ int MWDialogue::SelectWrapper::getArgument() const case 68: return 0; case 69: return 3; case 70: return 2; + + // attributes + case 10: return 0; + case 51: return 1; + case 52: return 2; + case 53: return 3; + case 54: return 4; + case 55: return 5; + case 56: return 6; + case 57: return 7; + + // skills + case 11: return 0; + case 12: return 1; + case 13: return 2; + case 14: return 3; + case 15: return 4; + case 16: return 5; + case 17: return 6; + case 18: return 7; + case 19: return 8; + case 20: return 9; + case 21: return 10; + case 22: return 11; + case 23: return 12; + case 24: return 13; + case 25: return 14; + case 26: return 15; + case 27: return 16; + case 28: return 17; + case 29: return 18; + case 30: return 19; + case 31: return 20; + case 32: return 21; + case 33: return 22; + case 34: return 23; + case 35: return 24; + case 36: return 25; + case 37: return 26; } return 0; @@ -125,6 +175,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_Journal, Function_Item, Function_Dead, Function_Choice, Function_AiSetting, + Function_PcAttribute, Function_PcSkill, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 3ff55eb614..5155749271 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -27,7 +27,8 @@ namespace MWDialogue Function_SameFaction, Function_Choice, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, - Function_AiSetting + Function_AiSetting, + Function_PcAttribute, Function_PcSkill }; enum Type From e97f3003ab9fcd3d599dc1dac4eaabc766a2d17d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 12:28:40 +0100 Subject: [PATCH 209/255] Issue #219: added expelled status tracking; implemented expelled filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 4 ---- apps/openmw/mwdialogue/filter.cpp | 13 +++++++++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 4 +++- apps/openmw/mwdialogue/selectwrapper.hpp | 3 ++- apps/openmw/mwmechanics/npcstats.cpp | 5 +++++ apps/openmw/mwmechanics/npcstats.hpp | 3 +++ 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index a9e5640782..b5ce4c5361 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -113,10 +113,6 @@ namespace MWDialogue iss >> ifunction; switch(ifunction) { - case 39://PC Expelled - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 43://PC Crime level if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 4000d3150d..a901fc8e06 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -295,6 +295,19 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return MWWorld::Class::get (player).getCreatureStats (player). getMagicEffects().get (132).mMagnitude!=0; + case SelectWrapper::Function_PcExpelled: + { + if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty()) + return false; + + std::string faction = + MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first; + + std::set<std::string>& expelled = MWWorld::Class::get (player).getNpcStats (player).getExpelled(); + + return expelled.find (faction)!=expelled.end(); + } + default: throw std::runtime_error ("unknown boolean select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 6b604c1aae..96bf932a1a 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -66,7 +66,8 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: return Function_PcSkill; - // 38, 39 + // 38 + case 39: return Function_PcExpelled; case 40: return Function_PcCommonDisease; case 41: return Function_PcBlightDisease; // 42-45 @@ -191,6 +192,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_Id, Function_Faction, Function_Class, Function_Race, Function_Cell, Function_SameFaction, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, + Function_PcExpelled, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 5155749271..2c8c9f24e1 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -28,7 +28,8 @@ namespace MWDialogue Function_Choice, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_AiSetting, - Function_PcAttribute, Function_PcSkill + Function_PcAttribute, Function_PcSkill, + Function_PcExpelled }; enum Type diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index cc054c1dcd..0116b6a964 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -81,6 +81,11 @@ std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks() return mFactionRank; } +std::set<std::string>& MWMechanics::NpcStats::getExpelled() +{ + return mExpelled; +} + const std::map<std::string, int>& MWMechanics::NpcStats::getFactionRanks() const { return mFactionRank; diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index a6f7adaf11..ca0ed07df5 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -47,6 +47,7 @@ namespace MWMechanics unsigned int mMovementFlags; Stat<float> mSkill[27]; int mBounty; + std::set<std::string> mExpelled; int mLevelProgress; // 0-10 @@ -75,6 +76,8 @@ namespace MWMechanics Stat<float>& getSkill (int index); std::map<std::string, int>& getFactionRanks(); + + std::set<std::string>& getExpelled(); bool isSameFaction (const NpcStats& npcStats) const; ///< Do *this and \a npcStats share a faction? From 5fdc7ad809f380360965efe05160d4dd65e4e483 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sat, 10 Nov 2012 13:07:26 +0100 Subject: [PATCH 210/255] forgot to add file --- files/mygui/openmw_persuasion_dialog.layout | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 files/mygui/openmw_persuasion_dialog.layout diff --git a/files/mygui/openmw_persuasion_dialog.layout b/files/mygui/openmw_persuasion_dialog.layout new file mode 100644 index 0000000000..87851b479b --- /dev/null +++ b/files/mygui/openmw_persuasion_dialog.layout @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<MyGUI type="Layout"> + <Widget type="Window" skin="MW_Dialog" layer="Windows" position="0 0 220 194" name="_Main"> + + <Widget type="TextBox" skin="NormalText" position="0 6 220 24"> + <Property key="Caption" value="#{sPersuasionMenuTitle}"/> + <Property key="TextAlign" value="Center"/> + </Widget> + + <Widget type="TextBox" skin="SandText" position="8 156 208 24" name="GoldLabel"> + <Property key="TextAlign" value="Left VCenter"/> + </Widget> + + <Widget type="Widget" skin="MW_Box" position="8 32 196 115"> + <Widget type="AutoSizedButton" skin="SandTextButton" position="4 0 0 18" name="AdmireButton"> + <Property key="Caption" value="#{sAdmire}"/> + <Property key="TextAlign" value="Left"/> + </Widget> + <Widget type="AutoSizedButton" skin="SandTextButton" position="4 18 0 18" name="IntimidateButton"> + <Property key="Caption" value="#{sIntimidate}"/> + <Property key="TextAlign" value="Left"/> + </Widget> + <Widget type="AutoSizedButton" skin="SandTextButton" position="4 36 0 18" name="TauntButton"> + <Property key="Caption" value="#{sTaunt}"/> + <Property key="TextAlign" value="Left"/> + </Widget> + <Widget type="AutoSizedButton" skin="SandTextButton" position="4 54 0 18" name="Bribe10Button"> + <Property key="Caption" value="#{sBribe 10 Gold}"/> + <Property key="TextAlign" value="Left"/> + </Widget> + <Widget type="AutoSizedButton" skin="SandTextButton" position="4 72 0 18" name="Bribe100Button"> + <Property key="Caption" value="#{sBribe 100 Gold}"/> + <Property key="TextAlign" value="Left"/> + </Widget> + <Widget type="AutoSizedButton" skin="SandTextButton" position="4 90 0 18" name="Bribe1000Button"> + <Property key="Caption" value="#{sBribe 1000 Gold}"/> + <Property key="TextAlign" value="Left"/> + </Widget> + </Widget> + + <Widget type="AutoSizedButton" skin="MW_Button" position="204 156 0 24" name="CancelButton"> + <Property key="ExpandDirection" value="Left"/> + <Property key="Caption" value="#{sCancel}"/> + </Widget> + + </Widget> + +</MyGUI> From 7e8d4bb3c928fd2c1047e9111b894ebe83ef7d1f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 13:20:41 +0100 Subject: [PATCH 211/255] Issue #219: added various creature and NPC stats; implemented respective filters --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 12 -------- apps/openmw/mwdialogue/filter.cpp | 15 ++++++++++ apps/openmw/mwdialogue/selectwrapper.cpp | 9 +++++- apps/openmw/mwdialogue/selectwrapper.hpp | 5 +++- apps/openmw/mwmechanics/creaturestats.cpp | 22 ++++++++++++++- apps/openmw/mwmechanics/creaturestats.hpp | 17 +++++++++-- apps/openmw/mwmechanics/npcstats.cpp | 28 ++++++++++++++++++- apps/openmw/mwmechanics/npcstats.hpp | 10 +++++++ 8 files changed, 100 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index b5ce4c5361..ff5ad40c28 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -125,10 +125,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 60://PC Vampire - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 61://Level if(!selectCompare<int,int>(comp,1,select.mI)) return false; break; @@ -137,10 +133,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 63://Talked to PC - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 64://PC Health if(!selectCompare<int,int>(comp,50,select.mI)) return false; break; @@ -149,10 +141,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 66://Friend hit - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 71://Should Attack if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index a901fc8e06..3dac9a07a0 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -241,6 +241,13 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return static_cast<int> (MWWorld::Class::get (player). getNpcStats (player).getSkill (select.getArgument()).getModified()); + case SelectWrapper::Function_FriendlyHit: + { + int hits = MWWorld::Class::get (mActor).getCreatureStats (mActor).getFriendlyHits(); + + return hits>4 ? 4 : hits; + } + default: throw std::runtime_error ("unknown integer select function"); @@ -307,6 +314,14 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return expelled.find (faction)!=expelled.end(); } + + case SelectWrapper::Function_PcVampire: + + return MWWorld::Class::get (player).getNpcStats (player).isVampire(); + + case SelectWrapper::Function_TalkedToPc: + + return MWWorld::Class::get (mActor).getCreatureStats (mActor).hasTalkedToPlayer(); default: diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 96bf932a1a..5211edba59 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -76,7 +76,12 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 50: return Function_Choice; case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute; case 58: return Function_PcCorprus; - // 59-66 + // 59 + case 60: return Function_PcVampire; + // 61, 62 + case 63: return Function_TalkedToPc; + // 64, 65 + case 66: return Function_FriendlyHit; case 67: case 68: case 69: case 70: return Function_AiSetting; // 71-77 } @@ -177,6 +182,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_Choice, Function_AiSetting, Function_PcAttribute, Function_PcSkill, + Function_FriendlyHit, Function_None // end marker }; @@ -193,6 +199,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_SameFaction, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_PcExpelled, + Function_PcVampire, Function_TalkedToPc, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 2c8c9f24e1..14f2926329 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -29,7 +29,10 @@ namespace MWDialogue Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_AiSetting, Function_PcAttribute, Function_PcSkill, - Function_PcExpelled + Function_PcExpelled, + Function_PcVampire, + Function_FriendlyHit, + Function_TalkedToPc }; enum Type diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 10b9b2f7e4..9ee7ca7c27 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -10,7 +10,7 @@ namespace MWMechanics { CreatureStats::CreatureStats() - : mLevel (0), mLevelHealthBonus(0.f), mDead (false) + : mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false) { for (int i=0; i<4; ++i) mAiSettings[i] = 0; @@ -216,4 +216,24 @@ namespace MWMechanics { return mSpells.hasBlightDisease(); } + + int CreatureStats::getFriendlyHits() const + { + return mFriendlyHits; + } + + void CreatureStats::friendlyHit() + { + ++mFriendlyHits; + } + + bool CreatureStats::hasTalkedToPlayer() const + { + return mTalkedTo; + } + + void CreatureStats::talkedToPlayer() + { + mTalkedTo = true; + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index bbb8b8b300..937cb61cc7 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -27,7 +27,9 @@ namespace MWMechanics int mAiSettings[4]; AiSequence mAiSequence; float mLevelHealthBonus; - bool mDead; + bool mDead; + int mFriendlyHits; + bool mTalkedTo; public: CreatureStats(); @@ -99,7 +101,18 @@ namespace MWMechanics bool hasCommonDisease() const; - bool hasBlightDisease() const; + bool hasBlightDisease() const; + + int getFriendlyHits() const; + ///< Number of friendly hits received. + + void friendlyHit(); + ///< Increase number of friendly hits by one. + + bool hasTalkedToPlayer() const; + ///< Has this creature talked with the player before? + + void talkedToPlayer(); }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 0116b6a964..3402779d4b 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -19,7 +19,7 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0) -, mLevelProgress(0), mDisposition(0) +, mLevelProgress(0), mDisposition(0), mVampire (0) { mSkillIncreases.resize (ESM::Attribute::Length); @@ -274,3 +274,29 @@ void MWMechanics::NpcStats::setBounty (int bounty) { mBounty = bounty; } + +int MWMechanics::NpcStats::getFactionReputation (const std::string& faction) const +{ + std::map<std::string, int>::const_iterator iter = mFactionReputation.find (faction); + + if (iter==mFactionReputation.end()) + return 0; + + return iter->second; +} + +void MWMechanics::NpcStats::setFactionReputation (const std::string& faction, int value) +{ + mFactionReputation[faction] = value; +} + +bool MWMechanics::NpcStats::isVampire() const +{ + return mVampire; +} + +void MWMechanics::NpcStats::setVampire (bool set) +{ + mVampire = set; +} + diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index ca0ed07df5..1ffc06cdf2 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -48,6 +48,8 @@ namespace MWMechanics Stat<float> mSkill[27]; int mBounty; std::set<std::string> mExpelled; + std::map<std::string, int> mFactionReputation; + bool mVampire; int mLevelProgress; // 0-10 @@ -108,6 +110,14 @@ namespace MWMechanics int getBounty() const; void setBounty (int bounty); + + int getFactionReputation (const std::string& faction) const; + + void setFactionReputation (const std::string& faction, int value); + + bool isVampire() const; + + void setVampire (bool set); }; } From f8fcca64b682c321e6144aac2990bd3471ac249b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 13:31:10 +0100 Subject: [PATCH 212/255] Issue #219: Proper implementation of talked to PC filter --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 13 +++++++++---- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 1 + apps/openmw/mwdialogue/filter.cpp | 6 ++++-- apps/openmw/mwdialogue/filter.hpp | 3 ++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index ff5ad40c28..005997a941 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -38,6 +38,7 @@ #include "../mwclass/npc.hpp" #include "../mwmechanics/npcstats.hpp" +#include "../mwmechanics/creaturestats.hpp" #include "filter.hpp" @@ -224,6 +225,10 @@ namespace MWDialogue mIsInChoice = false; mActor = actor; + + MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor); + mTalkedTo = creatureStats.hasTalkedToPlayer(); + creatureStats.talkedToPlayer(); mActorKnownTopics.clear(); @@ -240,7 +245,7 @@ namespace MWDialogue const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); - Filter filter (actor, mChoice); + Filter filter (actor, mChoice, mTalkedTo); MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) @@ -344,7 +349,7 @@ namespace MWDialogue const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); - Filter filter (mActor, mChoice); + Filter filter (mActor, mChoice, mTalkedTo); MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); for (; it != dialogs.end(); ++it) @@ -431,7 +436,7 @@ namespace MWDialogue ESM::Dialogue ndialogue = mDialogueMap[keyword]; if(ndialogue.mType == ESM::Dialogue::Topic) { - Filter filter (mActor, mChoice); + Filter filter (mActor, mChoice, mTalkedTo); for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) @@ -478,7 +483,7 @@ namespace MWDialogue ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; if(ndialogue.mType == ESM::Dialogue::Topic) { - Filter filter (mActor, mChoice); + Filter filter (mActor, mChoice, mTalkedTo); for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index e3e9fd7529..d6f8250fc0 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -40,6 +40,7 @@ namespace MWDialogue bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code); void executeScript(std::string script); MWWorld::Ptr mActor; + bool mTalkedTo; void printError(std::string error); diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 3dac9a07a0..9be8f41506 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -321,7 +321,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co case SelectWrapper::Function_TalkedToPc: - return MWWorld::Class::get (mActor).getCreatureStats (mActor).hasTalkedToPlayer(); + return mTalkedToPlayer; default: @@ -329,7 +329,9 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co } } -MWDialogue::Filter::Filter (const MWWorld::Ptr& actor, int choice) : mActor (actor), mChoice (choice) {} +MWDialogue::Filter::Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer) +: mActor (actor), mChoice (choice), mTalkedToPlayer (talkedToPlayer) +{} bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const { diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index a849dc0167..6e0b96a0f1 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -16,6 +16,7 @@ namespace MWDialogue { MWWorld::Ptr mActor; int mChoice; + bool mTalkedToPlayer; bool testActor (const ESM::DialInfo& info) const; ///< Is this the right actor for this \a info? @@ -36,7 +37,7 @@ namespace MWDialogue public: - Filter (const MWWorld::Ptr& actor, int choice); + Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer); bool operator() (const ESM::DialInfo& info) const; ///< \return does the dialogue match? From d24e3eec9f4dcf17e5352eda162fbafe48def835 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 14:02:52 +0100 Subject: [PATCH 213/255] Issue #219: added filters for various player stats --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 8 --- apps/openmw/mwdialogue/filter.cpp | 55 ++++++++++++++++++- apps/openmw/mwdialogue/selectwrapper.cpp | 26 +++++++-- apps/openmw/mwdialogue/selectwrapper.hpp | 4 +- 4 files changed, 79 insertions(+), 14 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 005997a941..e94ded2423 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -114,10 +114,6 @@ namespace MWDialogue iss >> ifunction; switch(ifunction) { - case 43://PC Crime level - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - case 48://Detected if(!selectCompare<int,int>(comp,1,select.mI)) return false; break; @@ -134,10 +130,6 @@ namespace MWDialogue if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; - case 64://PC Health - if(!selectCompare<int,int>(comp,50,select.mI)) return false; - break; - case 65://Creature target if(!selectCompare<int,int>(comp,0,select.mI)) return false; break; diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 9be8f41506..f5ea20b7b1 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -9,6 +9,7 @@ #include "../mwworld/class.hpp" #include "../mwworld/player.hpp" #include "../mwworld/containerstore.hpp" +#include "../mwworld/inventorystore.hpp" #include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/creaturestats.hpp" @@ -188,6 +189,26 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c return select.selectCompare (locals.mFloats.at (i)); } + case SelectWrapper::Function_PcHealthPercent: + { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + float ratio = MWWorld::Class::get (player).getCreatureStats (player).getHealth().getCurrent() / + MWWorld::Class::get (player).getCreatureStats (player).getHealth().getModified(); + + return select.selectCompare (ratio); + } + + case SelectWrapper::Function_PcDynamicStat: + { + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + + float value = MWWorld::Class::get (player).getCreatureStats (player). + getDynamic (select.getArgument()).getCurrent(); + + return select.selectCompare (value); + } + default: throw std::runtime_error ("unknown numeric select function"); @@ -247,7 +268,39 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return hits>4 ? 4 : hits; } + + case SelectWrapper::Function_PcLevel: + + return MWWorld::Class::get (player).getCreatureStats (player).getLevel(); + + case SelectWrapper::Function_PcGender: + { + MWWorld::LiveCellRef<ESM::NPC> *cellRef = player.get<ESM::NPC>(); + return cellRef->mBase->Female ? 0 : 1; + } + + case SelectWrapper::Function_PcClothingModifier: + { + MWWorld::InventoryStore& store = MWWorld::Class::get (player).getInventoryStore (player); + + int value = 0; + + for (int i=0; i<=15; ++i) // everything except thigns held in hands and amunition + { + MWWorld::ContainerStoreIterator slot = store.getSlot (i); + + if (slot!=store.end()) + value += MWWorld::Class::get (*slot).getValue (*slot); + } + + return value; + } + + case SelectWrapper::Function_PcCrimeLevel: + + return MWWorld::Class::get (player).getNpcStats (player).getBounty(); + default: throw std::runtime_error ("unknown integer select function"); @@ -322,7 +375,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co case SelectWrapper::Function_TalkedToPc: return mTalkedToPlayer; - + default: throw std::runtime_error ("unknown boolean select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 5211edba59..c143e96976 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -61,16 +61,21 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() switch (index) { - // 0-9 + // 0-5 + case 6: return Function_PcLevel; + case 7: return Function_PcHealthPercent; + case 8: case 9: return Function_PcDynamicStat; case 10: return Function_PcAttribute; case 11: case 12: case 13: case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: return Function_PcSkill; - // 38 + case 38: return Function_PcGender; case 39: return Function_PcExpelled; case 40: return Function_PcCommonDisease; case 41: return Function_PcBlightDisease; - // 42-45 + // 42 + case 42: return Function_PcClothingModifier; + case 43: return Function_PcCrimeLevel; case 46: return Function_SameFaction; // 47-49 case 50: return Function_Choice; @@ -80,7 +85,8 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 60: return Function_PcVampire; // 61, 62 case 63: return Function_TalkedToPc; - // 64, 65 + case 64: return Function_PcDynamicStat; + // 65 case 66: return Function_FriendlyHit; case 67: case 68: case 69: case 70: return Function_AiSetting; // 71-77 @@ -169,6 +175,11 @@ int MWDialogue::SelectWrapper::getArgument() const case 35: return 24; case 36: return 25; case 37: return 26; + + // dynamic stats + case 8: return 1; + case 9: return 2; + case 64: return 0; } return 0; @@ -183,12 +194,15 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_AiSetting, Function_PcAttribute, Function_PcSkill, Function_FriendlyHit, + Function_PcLevel, Function_PcGender, Function_PcClothingModifier, + Function_PcCrimeLevel, Function_None // end marker }; static const Function numericFunctions[] = { Function_Global, Function_Local, + Function_PcDynamicStat, Function_PcHealthPercent, Function_None // end marker }; @@ -233,6 +247,10 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const { Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race, Function_SameFaction, + Function_PcSkill, + Function_PcExpelled, + Function_PcVampire, + Function_PcCrimeLevel, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 14f2926329..fd51101d86 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -32,7 +32,9 @@ namespace MWDialogue Function_PcExpelled, Function_PcVampire, Function_FriendlyHit, - Function_TalkedToPc + Function_TalkedToPc, + Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat, + Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel }; enum Type From 79706bf60fe87805511c7b40fa132380e3be74d8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 14:31:58 +0100 Subject: [PATCH 214/255] Issue #219: dialogue manager cleanup --- apps/openmw/engine.cpp | 1 + apps/openmw/mwbase/dialoguemanager.hpp | 4 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 150 +++--------------- apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 44 +++-- apps/openmw/mwscript/statsextensions.cpp | 21 ++- 5 files changed, 61 insertions(+), 159 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index a75a60223b..d646d5acad 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -20,6 +20,7 @@ #include "mwscript/scriptmanagerimp.hpp" #include "mwscript/extensions.hpp" +#include "mwscript/interpretercontext.hpp" #include "mwsound/soundmanagerimp.hpp" diff --git a/apps/openmw/mwbase/dialoguemanager.hpp b/apps/openmw/mwbase/dialoguemanager.hpp index ccffc6b214..9ea3c810ab 100644 --- a/apps/openmw/mwbase/dialoguemanager.hpp +++ b/apps/openmw/mwbase/dialoguemanager.hpp @@ -33,8 +33,8 @@ namespace MWBase virtual void goodbye() = 0; - ///get the faction of the actor you are talking with - virtual std::string getFaction() const = 0; + virtual MWWorld::Ptr getActor() const = 0; + ///< Return the actor the player is currently talking to. //calbacks for the GUI virtual void keywordSelected (const std::string& keyword) = 0; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index e94ded2423..fece9dc262 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -6,23 +6,7 @@ #include <iterator> #include <components/esm/loaddial.hpp> - -#include "../mwbase/environment.hpp" -#include "../mwbase/world.hpp" -#include "../mwbase/scriptmanager.hpp" -#include "../mwbase/journal.hpp" -#include "../mwbase/windowmanager.hpp" -#include "../mwbase/mechanicsmanager.hpp" - -#include "../mwworld/class.hpp" -#include "../mwworld/refdata.hpp" -#include "../mwworld/player.hpp" -#include "../mwworld/containerstore.hpp" -#include "../mwworld/esmstore.hpp" - -#include "../mwgui/dialogue.hpp" - -#include <iostream> +#include <components/esm/loadinfo.hpp> #include <components/compiler/exception.hpp> #include <components/compiler/errorhandler.hpp> @@ -30,14 +14,24 @@ #include <components/compiler/locals.hpp> #include <components/compiler/output.hpp> #include <components/compiler/scriptparser.hpp> + #include <components/interpreter/interpreter.hpp> +#include "../mwbase/environment.hpp" +#include "../mwbase/world.hpp" +#include "../mwbase/scriptmanager.hpp" +#include "../mwbase/windowmanager.hpp" + +#include "../mwworld/class.hpp" +#include "../mwworld/containerstore.hpp" +#include "../mwworld/esmstore.hpp" + +#include "../mwgui/dialogue.hpp" + #include "../mwscript/compilercontext.hpp" #include "../mwscript/interpretercontext.hpp" #include "../mwscript/extensions.hpp" -#include "../mwclass/npc.hpp" -#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/creaturestats.hpp" #include "filter.hpp" @@ -69,22 +63,6 @@ namespace return false; } - template<typename T1, typename T2> - bool selectCompare (char comp, T1 value1, T2 value2) - { - switch (comp) - { - case '0': return value1==value2; - case '1': return value1!=value2; - case '2': return value1>value2; - case '3': return value1>=value2; - case '4': return value1<value2; - case '5': return value1<=value2; - } - - throw std::runtime_error ("unknown compare type in dialogue info select"); - } - //helper function std::string::size_type find_str_ci(const std::string& str, const std::string& substr,size_t pos) { @@ -94,77 +72,6 @@ namespace namespace MWDialogue { - - - bool DialogueManager::functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice) - { - for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.mSelects.begin()); - iter != info.mSelects.end(); ++iter) - { - ESM::DialInfo::SelectStruct select = *iter; - char type = select.mSelectRule[1]; - if(type == '1') - { - char comp = select.mSelectRule[4]; - std::string name = select.mSelectRule.substr (5); - std::string function = select.mSelectRule.substr(2,2); - - int ifunction; - std::istringstream iss(function); - iss >> ifunction; - switch(ifunction) - { - case 48://Detected - if(!selectCompare<int,int>(comp,1,select.mI)) return false; - break; - - case 49://Alarmed - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 61://Level - if(!selectCompare<int,int>(comp,1,select.mI)) return false; - break; - - case 62://Attacked - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 65://Creature target - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - case 71://Should Attack - if(!selectCompare<int,int>(comp,0,select.mI)) return false; - break; - - default: - break; - - } - } - } - - return true; - } - - bool DialogueManager::isMatching (const MWWorld::Ptr& actor, - const ESM::DialInfo::SelectStruct& select) const - { - return true; - } - - bool DialogueManager::isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const - { - // check DATAstruct - for (std::vector<ESM::DialInfo::SelectStruct>::const_iterator iter (info.mSelects.begin()); - iter != info.mSelects.end(); ++iter) - if (!isMatching (actor, *iter)) - return false; - - return true; - } - DialogueManager::DialogueManager (const Compiler::Extensions& extensions) : mCompilerContext (MWScript::CompilerContext::Type_Dialgoue), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) @@ -190,7 +97,7 @@ namespace MWDialogue mKnownTopics[toLower(topic)] = true; } - void DialogueManager::parseText (std::string text) + void DialogueManager::parseText (const std::string& text) { std::list<std::string>::iterator it; for(it = mActorKnownTopics.begin();it != mActorKnownTopics.end();++it) @@ -248,7 +155,7 @@ namespace MWDialogue for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); iter!=it->mInfo.end(); ++iter) { - if (filter (*iter) && isMatching (actor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter)) { if (!iter->mSound.empty()) { @@ -311,7 +218,7 @@ namespace MWDialogue return false; } - void DialogueManager::executeScript(std::string script) + void DialogueManager::executeScript (const std::string& script) { std::vector<Interpreter::Type_Code> code; if(compile(script,code)) @@ -351,7 +258,7 @@ namespace MWDialogue for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); iter!=it->mInfo.end(); ++iter) { - if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter)) { mActorKnownTopics.push_back(toLower(it->mId)); //does the player know the topic? @@ -433,7 +340,7 @@ namespace MWDialogue for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter)) { std::string text = iter->mResponse; std::string script = iter->mResultScript; @@ -480,7 +387,7 @@ namespace MWDialogue for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); iter!=ndialogue.mInfo.end(); ++iter) { - if (filter (*iter) && isMatching (mActor, *iter) && functionFilter(mActor,*iter,true)) + if (filter (*iter)) { mChoiceMap.clear(); mChoice = -1; @@ -501,7 +408,7 @@ namespace MWDialogue } } - void DialogueManager::printError (std::string error) + void DialogueManager::printError (const std::string& error) { MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); win->addText(error); @@ -515,22 +422,9 @@ namespace MWDialogue mIsInChoice = true; } - std::string DialogueManager::getFaction() const + MWWorld::Ptr DialogueManager::getActor() const { - if (mActor.getTypeName() != typeid(ESM::NPC).name()) - return ""; - - std::string factionID(""); - MWMechanics::NpcStats stats = MWWorld::Class::get(mActor).getNpcStats(mActor); - if(stats.getFactionRanks().empty()) - { - std::cout << "No faction for this actor!"; - } - else - { - factionID = stats.getFactionRanks().begin()->first; - } - return factionID; + return mActor; } void DialogueManager::goodbye() diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index d6f8250fc0..bc497c3994 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -3,53 +3,45 @@ #include "../mwbase/dialoguemanager.hpp" -#include <components/esm/loadinfo.hpp> +#include <map> +#include <list> #include <components/compiler/streamerrorhandler.hpp> -#include "../mwscript/compilercontext.hpp" -#include "../mwscript/interpretercontext.hpp" -#include <components/compiler/output.hpp> #include "../mwworld/ptr.hpp" -#include <map> +#include "../mwscript/compilercontext.hpp" namespace MWDialogue { class DialogueManager : public MWBase::DialogueManager { - bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo::SelectStruct& select) const; - - bool isMatching (const MWWorld::Ptr& actor, const ESM::DialInfo& info) const; - - bool functionFilter(const MWWorld::Ptr& actor, const ESM::DialInfo& info,bool choice); - - void parseText(std::string text); - - void updateTopics(); - - std::map<std::string,ESM::Dialogue> mDialogueMap; - std::map<std::string,bool> mKnownTopics;// Those are the topics the player knows. + std::map<std::string, ESM::Dialogue> mDialogueMap; + std::map<std::string, bool> mKnownTopics;// Those are the topics the player knows. std::list<std::string> mActorKnownTopics; MWScript::CompilerContext mCompilerContext; std::ostream mErrorStream; Compiler::StreamErrorHandler mErrorHandler; - - - bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code); - void executeScript(std::string script); + MWWorld::Ptr mActor; bool mTalkedTo; - void printError(std::string error); - int mChoice; - std::map<std::string,int> mChoiceMap; + std::map<std::string, int> mChoiceMap; std::string mLastTopic; ESM::DialInfo mLastDialogue; bool mIsInChoice; + void parseText (const std::string& text); + + void updateTopics(); + + bool compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code); + void executeScript (const std::string& script); + + void printError (const std::string& error); + public: DialogueManager (const Compiler::Extensions& extensions); @@ -62,8 +54,8 @@ namespace MWDialogue virtual void goodbye(); - ///get the faction of the actor you are talking with - virtual std::string getFaction() const; + virtual MWWorld::Ptr getActor() const; + ///< Return the actor the player is currently talking to. //calbacks for the GUI virtual void keywordSelected (const std::string& keyword); diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 0c4c6d144f..4fbb81b37b 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -28,6 +28,21 @@ #include "interpretercontext.hpp" #include "ref.hpp" +namespace +{ + std::string getDialogueActorFaction() + { + MWWorld::Ptr actor = MWBase::Environment::get().getDialogueManager()->getActor(); + + MWMechanics::NpcStats stats = MWWorld::Class::get (actor).getNpcStats (actor); + + if (stats.getFactionRanks().empty()) + throw std::runtime_error ( + "failed to determine dialogue actors faction (because actor is factionless)"); + + return stats.getFactionRanks().begin()->first; + } +} namespace MWScript { @@ -450,7 +465,7 @@ namespace MWScript if(arg0==0) { - factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); + factionID = getDialogueActorFaction(); } else { @@ -479,7 +494,7 @@ namespace MWScript if(arg0==0) { - factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); + factionID = getDialogueActorFaction(); } else { @@ -512,7 +527,7 @@ namespace MWScript if(arg0==0) { - factionID = MWBase::Environment::get().getDialogueManager()->getFaction(); + factionID = getDialogueActorFaction(); } else { From 6dc2214502bef63c8314764aa313e919c09306b3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 14:52:44 +0100 Subject: [PATCH 215/255] Issue #219: more DialogueManager refactoring --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 117 +++++++----------- apps/openmw/mwdialogue/filter.cpp | 11 ++ apps/openmw/mwdialogue/filter.hpp | 3 + 3 files changed, 60 insertions(+), 71 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index fece9dc262..ee376fcf01 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -140,37 +140,28 @@ namespace MWDialogue updateTopics(); //greeting - bool greetingFound = false; const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); Filter filter (actor, mChoice, mTalkedTo); - MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); - for (; it != dialogs.end(); ++it) + for (MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); it != dialogs.end(); ++it) { if(it->mType == ESM::Dialogue::Greeting) { - if (greetingFound) break; - for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); - iter!=it->mInfo.end(); ++iter) + if (const ESM::DialInfo *info = filter.search (*it)) { - if (filter (*iter)) + if (!info->mSound.empty()) { - if (!iter->mSound.empty()) - { - // TODO play sound - } - - std::string text = iter->mResponse; - parseText(text); - win->addText(iter->mResponse); - executeScript(iter->mResultScript); - greetingFound = true; - mLastTopic = it->mId; - mLastDialogue = *iter; - break; + // TODO play sound } + + parseText (info->mResponse); + win->addText (info->mResponse); + executeScript (info->mResultScript); + mLastTopic = it->mId; + mLastDialogue = *info; + break; } } } @@ -243,30 +234,24 @@ namespace MWDialogue int choice = mChoice; mChoice = -1; mActorKnownTopics.clear(); - MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); const MWWorld::Store<ESM::Dialogue> &dialogs = MWBase::Environment::get().getWorld()->getStore().get<ESM::Dialogue>(); Filter filter (mActor, mChoice, mTalkedTo); - MWWorld::Store<ESM::Dialogue>::iterator it = dialogs.begin(); - for (; it != dialogs.end(); ++it) + for (MWWorld::Store<ESM::Dialogue>::iterator iter = dialogs.begin(); iter != dialogs.end(); ++iter) { - if(it->mType == ESM::Dialogue::Topic) + if (iter->mType == ESM::Dialogue::Topic) { - for (std::vector<ESM::DialInfo>::const_iterator iter (it->mInfo.begin()); - iter!=it->mInfo.end(); ++iter) + if (filter.search (*iter)) { - if (filter (*iter)) + mActorKnownTopics.push_back (toLower (iter->mId)); + + //does the player know the topic? + if (mKnownTopics.find (toLower (iter->mId)) != mKnownTopics.end()) { - mActorKnownTopics.push_back(toLower(it->mId)); - //does the player know the topic? - if(mKnownTopics.find(toLower(it->mId)) != mKnownTopics.end()) - { - keywordList.push_back(it->mId); - break; - } + keywordList.push_back (iter->mId); } } } @@ -317,6 +302,8 @@ namespace MWDialogue if (services & ESM::NPC::Enchanting) windowServices |= MWGui::DialogueWindow::Service_Enchant; + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); + win->setServices (windowServices); // sort again, because the previous sort was case-sensitive @@ -333,30 +320,25 @@ namespace MWDialogue if(mDialogueMap.find(keyword) != mDialogueMap.end()) { ESM::Dialogue ndialogue = mDialogueMap[keyword]; - if(ndialogue.mType == ESM::Dialogue::Topic) + if (mDialogueMap[keyword].mType == ESM::Dialogue::Topic) { Filter filter (mActor, mChoice, mTalkedTo); - for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); - iter!=ndialogue.mInfo.end(); ++iter) + if (const ESM::DialInfo *info = filter.search (mDialogueMap[keyword])) { - if (filter (*iter)) - { - std::string text = iter->mResponse; - std::string script = iter->mResultScript; + std::string text = info->mResponse; + std::string script = info->mResultScript; - parseText(text); + parseText (text); - MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - win->addTitle(keyword); - win->addText(iter->mResponse); + MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); + win->addTitle (keyword); + win->addText (info->mResponse); - executeScript(script); + executeScript (script); - mLastTopic = keyword; - mLastDialogue = *iter; - break; - } + mLastTopic = keyword; + mLastDialogue = *info; } } } @@ -372,38 +354,31 @@ namespace MWDialogue void DialogueManager::questionAnswered (const std::string& answer) { - if(mChoiceMap.find(answer) != mChoiceMap.end()) + if (mChoiceMap.find(answer) != mChoiceMap.end()) { mChoice = mChoiceMap[answer]; - std::vector<ESM::DialInfo>::const_iterator iter; - if(mDialogueMap.find(mLastTopic) != mDialogueMap.end()) + if (mDialogueMap.find(mLastTopic) != mDialogueMap.end()) { - ESM::Dialogue ndialogue = mDialogueMap[mLastTopic]; - if(ndialogue.mType == ESM::Dialogue::Topic) + if (mDialogueMap[mLastTopic].mType == ESM::Dialogue::Topic) { Filter filter (mActor, mChoice, mTalkedTo); - for (std::vector<ESM::DialInfo>::const_iterator iter = ndialogue.mInfo.begin(); - iter!=ndialogue.mInfo.end(); ++iter) + if (const ESM::DialInfo *info = filter.search (mDialogueMap[mLastTopic])) { - if (filter (*iter)) - { - mChoiceMap.clear(); - mChoice = -1; - mIsInChoice = false; - MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow(); - std::string text = iter->mResponse; - parseText(text); - win->addText(text); - executeScript(iter->mResultScript); - mLastTopic = mLastTopic; - mLastDialogue = *iter; - break; - } + mChoiceMap.clear(); + mChoice = -1; + mIsInChoice = false; + std::string text = info->mResponse; + parseText (text); + MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addText (text); + executeScript (info->mResultScript); + mLastTopic = mLastTopic; + mLastDialogue = *info; } } } + updateTopics(); } } diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index f5ea20b7b1..c1f2a808f7 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -390,3 +390,14 @@ bool MWDialogue::Filter::operator() (const ESM::DialInfo& info) const { return testActor (info) && testPlayer (info) && testSelectStructs (info); } + +const ESM::DialInfo *MWDialogue::Filter::search (const ESM::Dialogue& dialogue) const +{ + for (std::vector<ESM::DialInfo>::const_iterator iter = dialogue.mInfo.begin(); + iter!=dialogue.mInfo.end(); ++iter) + if ((*this) (*iter)) + return &*iter; + + return 0; +} + diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index 6e0b96a0f1..2a252edc3d 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -6,6 +6,7 @@ namespace ESM { struct DialInfo; + struct Dialogue; } namespace MWDialogue @@ -41,6 +42,8 @@ namespace MWDialogue bool operator() (const ESM::DialInfo& info) const; ///< \return does the dialogue match? + + const ESM::DialInfo *search (const ESM::Dialogue& dialogue) const; }; } From 7b1788b03bbc26f7f4b09be5e0d6aead65987c8a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Sat, 10 Nov 2012 15:11:21 +0100 Subject: [PATCH 216/255] minor fix --- apps/openmw/mwrender/player.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index 4b0b562c4e..8578788118 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -24,8 +24,7 @@ namespace MWRender mFreeLook(true), mHeight(128.f), mCameraDistance(300.f), - mDistanceAdjusted(false), - mAnimation(NULL) + mDistanceAdjusted(false) { mVanity.enabled = false; mVanity.allowed = true; From 50867e8d87b3efefb566016fa54d6094cb15430c Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sat, 10 Nov 2012 19:57:50 +0400 Subject: [PATCH 217/255] fix gender selection update, main model visibility and couple of crashes --- apps/openmw/mwgui/charactercreation.cpp | 4 +-- apps/openmw/mwgui/race.cpp | 43 ++++++++++++++++++------- apps/openmw/mwgui/race.hpp | 1 + apps/openmw/mwrender/animation.cpp | 1 - apps/openmw/mwrender/player.cpp | 9 ++++-- 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwgui/charactercreation.cpp b/apps/openmw/mwgui/charactercreation.cpp index 4778460551..1719c57687 100644 --- a/apps/openmw/mwgui/charactercreation.cpp +++ b/apps/openmw/mwgui/charactercreation.cpp @@ -461,10 +461,10 @@ void CharacterCreation::onRaceDialogBack() if (mRaceDialog) { const ESM::NPC &data = mRaceDialog->getResult(); - mPlayerRaceId = data.mId; + mPlayerRaceId = data.mRace; if (!mPlayerRaceId.empty()) { MWBase::Environment::get().getMechanicsManager()->setPlayerRace( - data.mId, + data.mRace, data.isMale(), data.mHead, data.mHair diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index ff7c01ade6..fbebbe8970 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -5,6 +5,7 @@ #include <boost/algorithm/string.hpp> #include <boost/lexical_cast.hpp> +#include <boost/format.hpp> #include "../mwworld/esmstore.hpp" @@ -108,6 +109,8 @@ void RaceDialog::open() MWBase::Environment::get().getWorld ()->setupExternalRendering (*mPreview); mPreview->update (0); + setRaceId(mPreview->getPrototype().mRace); + mPreviewImage->setImageTexture ("CharacterHeadPreview"); } @@ -174,11 +177,21 @@ void RaceDialog::onHeadRotate(MyGUI::ScrollBar*, size_t _position) void RaceDialog::onSelectPreviousGender(MyGUI::Widget*) { mGenderIndex = wrap(mGenderIndex - 1, 2); + + mFaceIndex = 0; + mHairIndex = 0; + + updatePreview(); } void RaceDialog::onSelectNextGender(MyGUI::Widget*) { mGenderIndex = wrap(mGenderIndex + 1, 2); + + mFaceIndex = 0; + mHairIndex = 0; + + updatePreview(); } void RaceDialog::onSelectPreviousFace(MyGUI::Widget*) @@ -215,6 +228,18 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) mCurrentRaceId = *raceId; + mFaceIndex = 0; + mHairIndex = 0; + + updatePreview(); + updateSkills(); + updateSpellPowers(); +} + +// update widget content + +void RaceDialog::updatePreview() +{ ESM::NPC record = mPreview->getPrototype(); record.mRace = mCurrentRaceId; record.setIsMale(mGenderIndex == 0); @@ -222,27 +247,21 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) std::string prefix = "b_n_" + mCurrentRaceId + ((record.isMale()) ? "_m_" : "_f_"); - record.mHead = prefix + "head_01"; - record.mHair = prefix + "hair_01"; + std::string headIndex = (boost::format("%02d") % (mFaceIndex + 1)).str(); + std::string hairIndex = (boost::format("%02d") % (mHairIndex + 1)).str(); + + record.mHead = prefix + "head_" + headIndex; + record.mHair = prefix + "hair_" + hairIndex; const MWWorld::Store<ESM::BodyPart> &parts = MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); if (parts.search(record.mHair) == 0) { - record.mHair = prefix + "hair01"; + record.mHair = prefix + "hair" + hairIndex; } - - mFaceIndex = 0; - mHairIndex = 0; - mPreview->setPrototype(record); - - updateSkills(); - updateSpellPowers(); } -// update widget content - void RaceDialog::updateRaces() { mRaceList->removeAllItems(); diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index ec73d1c3a4..fbed39baf7 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -78,6 +78,7 @@ namespace MWGui void updateRaces(); void updateSkills(); void updateSpellPowers(); + void updatePreview(); MyGUI::ImageBox* mPreviewImage; MyGUI::ListBox* mRaceList; diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index ef92497e55..2a3b8cf437 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -7,7 +7,6 @@ #include <OgreSubMesh.h> #include <OgreSceneManager.h> - namespace MWRender { diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index 8578788118..be2a793e8d 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -310,10 +310,13 @@ namespace MWRender void Player::setAnimation(NpcAnimation *anim) { - if (mAnimation) { - delete mAnimation; - } + delete mAnimation; mAnimation = anim; + + mPlayerNode->setVisible( + mVanity.enabled || mPreviewMode || !mFirstPersonView, + false + ); } void Player::setHeight(float height) From 0d33d005a5cca0dfea7c3d6b822cef62d2253a60 Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sat, 10 Nov 2012 21:30:16 +0400 Subject: [PATCH 218/255] head/hair selection --- apps/openmw/mwgui/race.cpp | 54 ++++++++++++++++++++++++++++++++------ apps/openmw/mwgui/race.hpp | 1 + 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index fbebbe8970..fd64c6342c 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -110,6 +110,7 @@ void RaceDialog::open() mPreview->update (0); setRaceId(mPreview->getPrototype().mRace); + recountParts(); mPreviewImage->setImageTexture ("CharacterHeadPreview"); } @@ -146,6 +147,35 @@ int wrap(int index, int max) return index; } +int countParts(const std::string &part, const std::string &race, bool male) +{ + const MWWorld::Store<ESM::BodyPart> &store = + MWBase::Environment::get().getWorld()->getStore().get<ESM::BodyPart>(); + + std::string prefix = + "b_n_" + race + ((male) ? "_m_" : "_f_") + part; + + std::string suffix; + suffix.reserve(prefix.size() + 3); + + int count = -1; + do { + ++count; + suffix = "_" + (boost::format("%02d") % (count + 1)).str(); + } + while (store.search(prefix + suffix) != 0); + + if (count == 0 && part == "hair") { + count = -1; + do { + ++count; + suffix = (boost::format("%02d") % (count + 1)).str(); + } + while (store.search(prefix + suffix) != 0); + } + return count; +} + void RaceDialog::close() { delete mPreview; @@ -178,9 +208,7 @@ void RaceDialog::onSelectPreviousGender(MyGUI::Widget*) { mGenderIndex = wrap(mGenderIndex - 1, 2); - mFaceIndex = 0; - mHairIndex = 0; - + recountParts(); updatePreview(); } @@ -188,30 +216,32 @@ void RaceDialog::onSelectNextGender(MyGUI::Widget*) { mGenderIndex = wrap(mGenderIndex + 1, 2); - mFaceIndex = 0; - mHairIndex = 0; - + recountParts(); updatePreview(); } void RaceDialog::onSelectPreviousFace(MyGUI::Widget*) { mFaceIndex = wrap(mFaceIndex - 1, mFaceCount); + updatePreview(); } void RaceDialog::onSelectNextFace(MyGUI::Widget*) { mFaceIndex = wrap(mFaceIndex + 1, mFaceCount); + updatePreview(); } void RaceDialog::onSelectPreviousHair(MyGUI::Widget*) { mHairIndex = wrap(mHairIndex - 1, mHairCount); + updatePreview(); } void RaceDialog::onSelectNextHair(MyGUI::Widget*) { mHairIndex = wrap(mHairIndex - 1, mHairCount); + updatePreview(); } void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) @@ -228,14 +258,22 @@ void RaceDialog::onSelectRace(MyGUI::ListBox* _sender, size_t _index) mCurrentRaceId = *raceId; - mFaceIndex = 0; - mHairIndex = 0; + recountParts(); updatePreview(); updateSkills(); updateSpellPowers(); } +void RaceDialog::recountParts() +{ + mFaceIndex = 0; + mHairIndex = 0; + + mFaceCount = countParts("head", mCurrentRaceId, mGenderIndex == 0); + mHairCount = countParts("hair", mCurrentRaceId, mGenderIndex == 0); +} + // update widget content void RaceDialog::updatePreview() diff --git a/apps/openmw/mwgui/race.hpp b/apps/openmw/mwgui/race.hpp index fbed39baf7..e0dc3306a8 100644 --- a/apps/openmw/mwgui/race.hpp +++ b/apps/openmw/mwgui/race.hpp @@ -79,6 +79,7 @@ namespace MWGui void updateSkills(); void updateSpellPowers(); void updatePreview(); + void recountParts(); MyGUI::ImageBox* mPreviewImage; MyGUI::ListBox* mRaceList; From 623e00531d2e1ba50cb53ee0a2dc94a03113056a Mon Sep 17 00:00:00 2001 From: greye <greye@null.net> Date: Sat, 10 Nov 2012 21:54:43 +0400 Subject: [PATCH 219/255] fix reentering race selection --- apps/openmw/mwgui/race.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index fd64c6342c..d2714fb510 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -109,8 +109,15 @@ void RaceDialog::open() MWBase::Environment::get().getWorld ()->setupExternalRendering (*mPreview); mPreview->update (0); - setRaceId(mPreview->getPrototype().mRace); + const ESM::NPC proto = mPreview->getPrototype(); + setRaceId(proto.mRace); recountParts(); + + std::string index = proto.mHead.substr(proto.mHead.size() - 2, 2); + mFaceIndex = boost::lexical_cast<int>(index) - 1; + + index = proto.mHair.substr(proto.mHair.size() - 2, 2); + mHairIndex = boost::lexical_cast<int>(index) - 1; mPreviewImage->setImageTexture ("CharacterHeadPreview"); } @@ -240,7 +247,7 @@ void RaceDialog::onSelectPreviousHair(MyGUI::Widget*) void RaceDialog::onSelectNextHair(MyGUI::Widget*) { - mHairIndex = wrap(mHairIndex - 1, mHairCount); + mHairIndex = wrap(mHairIndex + 1, mHairCount); updatePreview(); } From 8e847fdc6e2718f51d83db913c7cb8847d4e2a8f Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Sun, 11 Nov 2012 19:18:41 +0100 Subject: [PATCH 220/255] fix speechcraft skill increasing when persuade didn't succeed --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 60ccda09fe..460a0e26de 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -977,7 +977,8 @@ namespace MWDialogue // practice skill MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, 0); + if (success) + MWWorld::Class::get(player).skillUsageSucceeded(player, ESM::Skill::Speechcraft, 0); // add status message to dialogue window From 77ba8c5117120f226642777c3d15f8e1870ea319 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Mon, 12 Nov 2012 13:23:25 +0100 Subject: [PATCH 221/255] Issue #219: implemented rank requirement filter --- apps/openmw/mwdialogue/filter.cpp | 68 ++++++++++++++++++++++++ apps/openmw/mwdialogue/filter.hpp | 8 +++ apps/openmw/mwdialogue/selectwrapper.cpp | 9 +++- apps/openmw/mwdialogue/selectwrapper.hpp | 3 +- apps/openmw/mwmechanics/npcstats.cpp | 28 ++++++++++ apps/openmw/mwmechanics/npcstats.hpp | 2 + 6 files changed, 115 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index c1f2a808f7..c51a418bf5 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -300,6 +300,30 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con case SelectWrapper::Function_PcCrimeLevel: return MWWorld::Class::get (player).getNpcStats (player).getBounty(); + + case SelectWrapper::Function_RankRequirement: + { + if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty()) + return 0; + + std::string faction = + MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first; + + int rank = getFactionRank (player, faction); + + if (rank>=9) + return 0; // max rank + + int result = 0; + + if (hasFactionRankSkillRequirements (player, faction, rank+1)) + result += 1; + + if (hasFactionRankReputationRequirements (player, faction, rank+1)) + result += 2; + + return result; + } default: @@ -382,6 +406,50 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co } } +int MWDialogue::Filter::getFactionRank (const MWWorld::Ptr& actor, const std::string& factionId) const +{ + MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor); + + std::map<std::string, int>::const_iterator iter = stats.getFactionRanks().find (factionId); + + if (iter==stats.getFactionRanks().end()) + return -1; + + return iter->second; +} + +bool MWDialogue::Filter::hasFactionRankSkillRequirements (const MWWorld::Ptr& actor, + const std::string& factionId, int rank) const +{ + if (rank<0 || rank>=10) + throw std::runtime_error ("rank index out of range"); + + if (!MWWorld::Class::get (actor).getNpcStats (actor).hasSkillsForRank (factionId, rank)) + return false; + + const ESM::Faction& faction = + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId); + + MWMechanics::CreatureStats& stats = MWWorld::Class::get (actor).getCreatureStats (actor); + + return stats.getAttribute (faction.mData.mAttribute1).getBase()>=faction.mData.mRankData[rank].mAttribute1 && + stats.getAttribute (faction.mData.mAttribute2).getBase()>=faction.mData.mRankData[rank].mAttribute2; +} + +bool MWDialogue::Filter::hasFactionRankReputationRequirements (const MWWorld::Ptr& actor, + const std::string& factionId, int rank) const +{ + if (rank<0 || rank>=10) + throw std::runtime_error ("rank index out of range"); + + MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor); + + const ESM::Faction& faction = + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId); + + return stats.getFactionReputation (factionId)>=faction.mData.mRankData[rank].mFactReaction; +} + MWDialogue::Filter::Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer) : mActor (actor), mChoice (choice), mTalkedToPlayer (talkedToPlayer) {} diff --git a/apps/openmw/mwdialogue/filter.hpp b/apps/openmw/mwdialogue/filter.hpp index 2a252edc3d..7c8f1116fb 100644 --- a/apps/openmw/mwdialogue/filter.hpp +++ b/apps/openmw/mwdialogue/filter.hpp @@ -36,6 +36,14 @@ namespace MWDialogue bool getSelectStructBoolean (const SelectWrapper& select) const; + int getFactionRank (const MWWorld::Ptr& actor, const std::string& factionId) const; + + bool hasFactionRankSkillRequirements (const MWWorld::Ptr& actor, const std::string& factionId, + int rank) const; + + bool hasFactionRankReputationRequirements (const MWWorld::Ptr& actor, const std::string& factionId, + int rank) const; + public: Filter (const MWWorld::Ptr& actor, int choice, bool talkedToPlayer); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index c143e96976..11f25741fd 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -61,7 +61,9 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() switch (index) { - // 0-5 + // 0, 1 + case 2: return Function_RankRequirement; + // 3-5 case 6: return Function_PcLevel; case 7: return Function_PcHealthPercent; case 8: case 9: return Function_PcDynamicStat; @@ -76,6 +78,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() // 42 case 42: return Function_PcClothingModifier; case 43: return Function_PcCrimeLevel; + // 44-45 case 46: return Function_SameFaction; // 47-49 case 50: return Function_Choice; @@ -196,6 +199,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_FriendlyHit, Function_PcLevel, Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, + Function_RankRequirement, Function_None // end marker }; @@ -250,7 +254,8 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const Function_PcSkill, Function_PcExpelled, Function_PcVampire, - Function_PcCrimeLevel, + Function_PcCrimeLevel, + Function_RankRequirement, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index fd51101d86..c12b39436a 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -34,7 +34,8 @@ namespace MWDialogue Function_FriendlyHit, Function_TalkedToPc, Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat, - Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel + Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, + Function_RankRequirement }; enum Type diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 23e5cf54b9..26415b6311 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -3,12 +3,15 @@ #include <cmath> #include <stdexcept> +#include <vector> +#include <algorithm> #include <boost/format.hpp> #include <components/esm/loadskil.hpp> #include <components/esm/loadclas.hpp> #include <components/esm/loadgmst.hpp> +#include <components/esm/loadfact.hpp> #include "../mwworld/esmstore.hpp" @@ -309,3 +312,28 @@ void MWMechanics::NpcStats::setReputation(int reputation) mReputation = reputation; } +bool MWMechanics::NpcStats::hasSkillsForRank (const std::string& factionId, int rank) const +{ + if (rank<0 || rank>=10) + throw std::runtime_error ("rank index out of range"); + + const ESM::Faction& faction = + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId); + + std::vector<int> skills; + + for (int i=0; i<6; ++i) + skills.push_back (static_cast<int> (getSkill (faction.mData.mSkillID[i]).getModified())); + + std::sort (skills.begin(), skills.end()); + + std::vector<int>::const_reverse_iterator iter = skills.rbegin(); + + const ESM::RankData& rankData = faction.mData.mRankData[rank]; + + if (*iter<rankData.mSkill1) + return false; + + return *++iter>=rankData.mSkill2; +} + diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 190c9a4753..46af216d9c 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -123,6 +123,8 @@ namespace MWMechanics bool isVampire() const; void setVampire (bool set); + + bool hasSkillsForRank (const std::string& factionId, int rank) const; }; } From 586ac3f5c60e9e1c60ffbf830c680a64c308d8aa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Mon, 12 Nov 2012 13:56:51 +0100 Subject: [PATCH 222/255] Issue #219: added some more stats filters; fixed two filters --- apps/openmw/mwdialogue/filter.cpp | 33 +++++++++++++++++++----- apps/openmw/mwdialogue/selectwrapper.cpp | 21 +++++++++------ apps/openmw/mwdialogue/selectwrapper.hpp | 7 ++--- 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index c51a418bf5..7a98eed7bb 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -208,6 +208,14 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c return select.selectCompare (value); } + + case SelectWrapper::Function_HealthPercent: + { + float ratio = MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getCurrent() / + MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getModified(); + + return select.selectCompare (ratio); + } default: @@ -250,7 +258,7 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con case SelectWrapper::Function_AiSetting: - return MWWorld::Class::get (player).getCreatureStats (player).getAiSetting (select.getArgument()); + return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAiSetting (select.getArgument()); case SelectWrapper::Function_PcAttribute: @@ -274,11 +282,8 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return MWWorld::Class::get (player).getCreatureStats (player).getLevel(); case SelectWrapper::Function_PcGender: - { - MWWorld::LiveCellRef<ESM::NPC> *cellRef = player.get<ESM::NPC>(); - - return cellRef->mBase->Female ? 0 : 1; - } + + return player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female ? 0 : 1; case SelectWrapper::Function_PcClothingModifier: { @@ -324,7 +329,11 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return result; } - + + case SelectWrapper::Function_Level: + + return MWWorld::Class::get (mActor).getCreatureStats (mActor).getLevel(); + default: throw std::runtime_error ("unknown integer select function"); @@ -361,6 +370,16 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return toLower (mActor.getCell()->mCell->mName)==select.getName(); + case SelectWrapper::Function_SameGender: + + return (player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female)== + (mActor.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female); + + case SelectWrapper::Function_SameRace: + + return toLower (mActor.get<ESM::NPC>()->mBase->mRace)!= + toLower (player.get<ESM::NPC>()->mBase->mRace); + case SelectWrapper::Function_SameFaction: return MWWorld::Class::get (mActor).getNpcStats (mActor).isSameFaction ( diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 11f25741fd..6ccc5d7e89 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -63,7 +63,9 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() { // 0, 1 case 2: return Function_RankRequirement; - // 3-5 + // 3 + case 4: return Function_HealthPercent; + // 5 case 6: return Function_PcLevel; case 7: return Function_PcHealthPercent; case 8: case 9: return Function_PcDynamicStat; @@ -75,10 +77,10 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 39: return Function_PcExpelled; case 40: return Function_PcCommonDisease; case 41: return Function_PcBlightDisease; - // 42 case 42: return Function_PcClothingModifier; case 43: return Function_PcCrimeLevel; - // 44-45 + case 44: return Function_SameGender; + case 45: return Function_SameRace; case 46: return Function_SameFaction; // 47-49 case 50: return Function_Choice; @@ -86,13 +88,14 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 58: return Function_PcCorprus; // 59 case 60: return Function_PcVampire; - // 61, 62 + case 61: return Function_Level; + // 62 case 63: return Function_TalkedToPc; case 64: return Function_PcDynamicStat; // 65 case 66: return Function_FriendlyHit; case 67: case 68: case 69: case 70: return Function_AiSetting; - // 71-77 + // 71 } return Function_False; @@ -199,7 +202,8 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_FriendlyHit, Function_PcLevel, Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, - Function_RankRequirement, + Function_RankRequirement, + Function_Level, Function_None // end marker }; @@ -207,6 +211,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const { Function_Global, Function_Local, Function_PcDynamicStat, Function_PcHealthPercent, + Function_HealthPercent, Function_None // end marker }; @@ -214,7 +219,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const { Function_False, Function_Id, Function_Faction, Function_Class, Function_Race, Function_Cell, - Function_SameFaction, + Function_SameGender, Function_SameRace, Function_SameFaction, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_PcExpelled, Function_PcVampire, Function_TalkedToPc, @@ -250,7 +255,7 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const static const Function functions[] = { Function_Faction, SelectWrapper::Function_Class, SelectWrapper::Function_Race, - Function_SameFaction, + Function_SameGender, Function_SameRace, Function_SameFaction, Function_PcSkill, Function_PcExpelled, Function_PcVampire, diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index c12b39436a..0668f312ec 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -24,7 +24,7 @@ namespace MWDialogue Function_Cell, Function_Local, Function_Global, - Function_SameFaction, + Function_SameGender, Function_SameRace, Function_SameFaction, Function_Choice, Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_AiSetting, @@ -35,9 +35,10 @@ namespace MWDialogue Function_TalkedToPc, Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat, Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, - Function_RankRequirement + Function_RankRequirement, + Function_HealthPercent, Function_Level }; - + enum Type { Type_None, From e2ccec99f0cbf6fb439f837f46883f43c51496ef Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Mon, 12 Nov 2012 14:02:49 +0100 Subject: [PATCH 223/255] Issue #219: added another missing PC stats filter --- apps/openmw/mwdialogue/filter.cpp | 4 ++++ apps/openmw/mwdialogue/selectwrapper.cpp | 4 ++-- apps/openmw/mwdialogue/selectwrapper.hpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 7a98eed7bb..21904b4bc2 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -334,6 +334,10 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con return MWWorld::Class::get (mActor).getCreatureStats (mActor).getLevel(); + case SelectWrapper::Function_PCReputation: + + return MWWorld::Class::get (player).getNpcStats (player).getReputation(); + default: throw std::runtime_error ("unknown integer select function"); diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index 6ccc5d7e89..ae5b8c582f 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -65,7 +65,7 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 2: return Function_RankRequirement; // 3 case 4: return Function_HealthPercent; - // 5 + case 5: return Function_PCReputation; case 6: return Function_PcLevel; case 7: return Function_PcHealthPercent; case 8: case 9: return Function_PcDynamicStat; @@ -203,7 +203,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_PcLevel, Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, Function_RankRequirement, - Function_Level, + Function_Level, Function_PCReputation, Function_None // end marker }; diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 0668f312ec..15cd5bfff9 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -36,7 +36,7 @@ namespace MWDialogue Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat, Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, Function_RankRequirement, - Function_HealthPercent, Function_Level + Function_HealthPercent, Function_Level, Function_PCReputation }; enum Type From 8aa1fd921ba450258ad4c08bda5221454c0d4b9f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 13 Nov 2012 14:19:43 +0100 Subject: [PATCH 224/255] fixed some stats related script instructions --- apps/openmw/mwscript/statsextensions.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 4fbb81b37b..83c25bc192 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -565,7 +565,7 @@ namespace MWScript { if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty()) { - //throw exception? + factionID = -1; } else { @@ -601,10 +601,11 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); -// Interpreter::Type_Integer value = runtime[0].mInteger; + Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - /// \todo modify disposition towards the player + MWWorld::Class::get (ptr).getNpcStats (ptr).setBaseDisposition + (MWWorld::Class::get (ptr).getNpcStats (ptr).getBaseDisposition() + value); } }; From c621a9f7e48ab8b06c74ed3bcf6a5cd55fdd557a Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 13 Nov 2012 14:29:00 +0100 Subject: [PATCH 225/255] added missing disposition script instructions --- apps/openmw/mwscript/docs/vmformat.txt | 6 ++- apps/openmw/mwscript/statsextensions.cpp | 48 ++++++++++++++++++++++-- 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index cb984e257c..1ea467e3b6 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -207,5 +207,9 @@ op 0x20001a0: ShowMap op 0x20001a1: FillMap op 0x20001a2: WakeUpPc op 0x20001a3: GetDeadCount -opcodes 0x20001a4-0x3ffffff unused +op 0x20001a4: SetDisposition +op 0x20001a5: SetDisposition, Explicit +op 0x20001a6: GetDisposition +op 0x20001a7: GetDisposition, Explicit +opcodes 0x20001a8-0x3ffffff unused diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 83c25bc192..bdac4748c7 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -608,6 +608,35 @@ namespace MWScript (MWWorld::Class::get (ptr).getNpcStats (ptr).getBaseDisposition() + value); } }; + + template<class R> + class OpSetDisposition : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + MWWorld::Class::get (ptr).getNpcStats (ptr).setBaseDisposition (value); + } + }; + + template<class R> + class OpGetDisposition : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push (MWWorld::Class::get (ptr).getNpcStats (ptr).getBaseDisposition()); + } + }; class OpGetDeadCount : public Interpreter::Opcode0 { @@ -666,6 +695,10 @@ namespace MWScript const int opcodeGetPCRankExplicit = 0x2000f; const int opcodeModDisposition = 0x200014d; const int opcodeModDispositionExplicit = 0x200014e; + const int opcodeSetDisposition = 0x20001a4; + const int opcodeSetDispositionExplicit = 0x20001a5; + const int opcodeGetDisposition = 0x20001a6; + const int opcodeGetDispositionExplicit = 0x20001a7; const int opcodeGetLevel = 0x200018c; const int opcodeGetLevelExplicit = 0x200018d; @@ -753,8 +786,12 @@ namespace MWScript extensions.registerInstruction("pcraiserank","/S",opcodePCRaiseRank); extensions.registerInstruction("pclowerrank","/S",opcodePCLowerRank); extensions.registerInstruction("pcjoinfaction","/S",opcodePCJoinFaction); - extensions.registerInstruction("moddisposition","l",opcodeModDisposition, + extensions.registerInstruction ("moddisposition","l",opcodeModDisposition, opcodeModDispositionExplicit); + extensions.registerInstruction ("setdisposition","l",opcodeSetDisposition, + opcodeSetDispositionExplicit); + extensions.registerFunction ("getdisposition",'l', "",opcodeGetDisposition, + opcodeGetDispositionExplicit); extensions.registerFunction("getpcrank",'l',"/S",opcodeGetPCRank,opcodeGetPCRankExplicit); extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit); @@ -828,11 +865,16 @@ namespace MWScript interpreter.installSegment3(opcodePCRaiseRank,new OpPCRaiseRank); interpreter.installSegment3(opcodePCLowerRank,new OpPCLowerRank); interpreter.installSegment3(opcodePCJoinFaction,new OpPCJoinFaction); - interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>); - interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>); interpreter.installSegment3(opcodeGetPCRank,new OpGetPCRank<ImplicitRef>); interpreter.installSegment3(opcodeGetPCRankExplicit,new OpGetPCRank<ExplicitRef>); + interpreter.installSegment5(opcodeModDisposition,new OpModDisposition<ImplicitRef>); + interpreter.installSegment5(opcodeModDispositionExplicit,new OpModDisposition<ExplicitRef>); + interpreter.installSegment5(opcodeSetDisposition,new OpSetDisposition<ImplicitRef>); + interpreter.installSegment5(opcodeSetDispositionExplicit,new OpSetDisposition<ExplicitRef>); + interpreter.installSegment5(opcodeGetDisposition,new OpGetDisposition<ImplicitRef>); + interpreter.installSegment5(opcodeGetDispositionExplicit,new OpGetDisposition<ExplicitRef>); + interpreter.installSegment5 (opcodeGetLevel, new OpGetLevel<ImplicitRef>); interpreter.installSegment5 (opcodeGetLevelExplicit, new OpGetLevel<ExplicitRef>); interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel<ImplicitRef>); From 2a1727d4c584d28cbace5e1738216cebb97a433f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 13 Nov 2012 15:35:46 +0100 Subject: [PATCH 226/255] improved error reporting for dialogue scripts (enabled via --script-verbose) --- apps/openmw/engine.cpp | 2 +- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 30 +++++++++++++------ apps/openmw/mwdialogue/dialoguemanagerimp.hpp | 3 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index d646d5acad..2299053cdc 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -356,7 +356,7 @@ void OMW::Engine::go() // Create dialog system mEnvironment.setJournal (new MWDialogue::Journal); - mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions)); + mEnvironment.setDialogueManager (new MWDialogue::DialogueManager (mExtensions, mVerboseScripts)); // Sets up the input system mEnvironment.setInputManager (new MWInput::InputManager (*mOgre, diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 881a02d003..6a0f9d71f5 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -75,11 +75,11 @@ namespace namespace MWDialogue { - DialogueManager::DialogueManager (const Compiler::Extensions& extensions) : + DialogueManager::DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose) : mCompilerContext (MWScript::CompilerContext::Type_Dialgoue), mErrorStream(std::cout.rdbuf()),mErrorHandler(mErrorStream) , mTemporaryDispositionChange(0.f) - , mPermanentDispositionChange(0.f) + , mPermanentDispositionChange(0.f), mScriptVerbose (scriptVerbose) { mChoice = -1; mIsInChoice = false; @@ -174,6 +174,8 @@ namespace MWDialogue bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code) { + bool success = true; + try { mErrorHandler.reset(); @@ -195,23 +197,33 @@ namespace MWDialogue Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false); scanner.scan (parser); - if(mErrorHandler.isGood()) - { - parser.getCode(code); - return true; - } - return false; + + if (!mErrorHandler.isGood()) + success = false; + + if (success) + parser.getCode (code); } catch (const Compiler::SourceException& /* error */) { // error has already been reported via error handler + success = false; } catch (const std::exception& error) { printError (std::string ("An exception has been thrown: ") + error.what()); + success = false; } - return false; + if (!success && mScriptVerbose) + { + std::cerr + << "compiling failed (dialogue script)" << std::endl + << cmd + << std::endl << std::endl; + } + + return success; } void DialogueManager::executeScript (const std::string& script) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp index 8e862f9328..9e1971b0fc 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.hpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.hpp @@ -35,6 +35,7 @@ namespace MWDialogue float mTemporaryDispositionChange; float mPermanentDispositionChange; + bool mScriptVerbose; void parseText (const std::string& text); @@ -47,7 +48,7 @@ namespace MWDialogue public: - DialogueManager (const Compiler::Extensions& extensions); + DialogueManager (const Compiler::Extensions& extensions, bool scriptVerbose); virtual void startDialogue (const MWWorld::Ptr& actor); From b046687f467452dfc85673ff7815bf3ed4790411 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Tue, 13 Nov 2012 16:11:03 +0100 Subject: [PATCH 227/255] added PCFacRep script instructions --- apps/openmw/mwscript/docs/vmformat.txt | 8 +- apps/openmw/mwscript/statsextensions.cpp | 148 +++++++++++++++++++++-- 2 files changed, 143 insertions(+), 13 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 1ea467e3b6..4ec9cfb99b 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -31,7 +31,13 @@ op 0x2000e: PCGetRank implicit op 0x2000f: PCGetRank explicit op 0x20010: AiWander op 0x20011: AiWander, explicit reference -op s 0x20012-0x3ffff unused +op 0x20012: GetPCFacRep +op 0x20013: GetPCFacRep, explicit reference +op 0x20014: SetPCFacRep +op 0x20015: SetPCFacRep, explicit reference +op 0x20016: ModPCFacRep +op 0x20017: ModPCFacRep, explicit reference +op s 0x20018-0x3ffff unused Segment 4: (not implemented yet) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index bdac4748c7..124eaf4c33 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -33,13 +33,13 @@ namespace std::string getDialogueActorFaction() { MWWorld::Ptr actor = MWBase::Environment::get().getDialogueManager()->getActor(); - + MWMechanics::NpcStats stats = MWWorld::Class::get (actor).getNpcStats (actor); - + if (stats.getFactionRanks().empty()) throw std::runtime_error ( "failed to determine dialogue actors faction (because actor is factionless)"); - + return stats.getFactionRanks().begin()->first; } } @@ -208,7 +208,7 @@ namespace MWScript .getDynamic (mIndex)); stat.setModified (value, 0); - + MWWorld::Class::get (ptr).getCreatureStats (ptr).setDynamic (mIndex, stat); } }; @@ -565,7 +565,7 @@ namespace MWScript { if(MWWorld::Class::get(ptr).getNpcStats(ptr).getFactionRanks().empty()) { - factionID = -1; + factionID = ""; } else { @@ -623,7 +623,7 @@ namespace MWScript MWWorld::Class::get (ptr).getNpcStats (ptr).setBaseDisposition (value); } - }; + }; template<class R> class OpGetDisposition : public Interpreter::Opcode0 @@ -636,8 +636,8 @@ namespace MWScript runtime.push (MWWorld::Class::get (ptr).getNpcStats (ptr).getBaseDisposition()); } - }; - + }; + class OpGetDeadCount : public Interpreter::Opcode0 { public: @@ -647,7 +647,112 @@ namespace MWScript std::string id = runtime.getStringLiteral (runtime[0].mInteger); runtime[0].mInteger = MWBase::Environment::get().getMechanicsManager()->countDeaths (id); } - }; + }; + + template<class R> + class OpGetPCFacRep : public Interpreter::Opcode1 + { + public: + + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) + { + std::string factionId; + + if (arg0==1) + { + factionId = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + } + else + { + MWWorld::Ptr ptr = R()(runtime); + + if (!MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().empty()) + factionId = MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().begin()->first; + } + + if (factionId.empty()) + throw std::runtime_error ("failed to determine faction"); + + boost::algorithm::to_lower (factionId); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + runtime.push ( + MWWorld::Class::get (player).getNpcStats (player).getFactionReputation (factionId)); + } + }; + + template<class R> + class OpSetPCFacRep : public Interpreter::Opcode1 + { + public: + + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) + { + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + std::string factionId; + + if (arg0==1) + { + factionId = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + } + else + { + MWWorld::Ptr ptr = R()(runtime); + + if (!MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().empty()) + factionId = MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().begin()->first; + } + + if (factionId.empty()) + throw std::runtime_error ("failed to determine faction"); + + boost::algorithm::to_lower (factionId); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWWorld::Class::get (player).getNpcStats (player).setFactionReputation (factionId, value); + } + }; + + template<class R> + class OpModPCFacRep : public Interpreter::Opcode1 + { + public: + + virtual void execute (Interpreter::Runtime& runtime, unsigned int arg0) + { + Interpreter::Type_Integer value = runtime[0].mInteger; + runtime.pop(); + + std::string factionId; + + if (arg0==1) + { + factionId = runtime.getStringLiteral (runtime[0].mInteger); + runtime.pop(); + } + else + { + MWWorld::Ptr ptr = R()(runtime); + + if (!MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().empty()) + factionId = MWWorld::Class::get (ptr).getNpcStats (ptr).getFactionRanks().begin()->first; + } + + if (factionId.empty()) + throw std::runtime_error ("failed to determine faction"); + + boost::algorithm::to_lower (factionId); + + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); + MWWorld::Class::get (player).getNpcStats (player).setFactionReputation (factionId, + MWWorld::Class::get (player).getNpcStats (player).getFactionReputation (factionId)+ + value); + } + }; const int numberOfAttributes = 8; @@ -704,9 +809,17 @@ namespace MWScript const int opcodeGetLevelExplicit = 0x200018d; const int opcodeSetLevel = 0x200018e; const int opcodeSetLevelExplicit = 0x200018f; - + const int opcodeGetDeadCount = 0x20001a3; + const int opcodeGetPCFacRep = 0x20012; + const int opcodeGetPCFacRepExplicit = 0x20013; + const int opcodeSetPCFacRep = 0x20014; + const int opcodeSetPCFacRepExplicit = 0x20015; + const int opcodeModPCFacRep = 0x20016; + const int opcodeModPCFacRepExplicit = 0x20017; + + void registerExtensions (Compiler::Extensions& extensions) { static const char *attributes[numberOfAttributes] = @@ -797,7 +910,11 @@ namespace MWScript extensions.registerInstruction("setlevel", "l", opcodeSetLevel, opcodeSetLevelExplicit); extensions.registerFunction("getlevel", 'l', "", opcodeGetLevel, opcodeGetLevelExplicit); - extensions.registerFunction("getdeadcount", 'l', "c", opcodeGetDeadCount); + extensions.registerFunction ("getdeadcount", 'l', "c", opcodeGetDeadCount); + + extensions.registerFunction ("getpcfacrep", 'l', "/c", opcodeGetPCFacRep, opcodeGetPCFacRepExplicit); + extensions.registerInstruction ("setpcfacrep", "/lc", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit); + extensions.registerInstruction ("modpcfacrep", "/lc", opcodeModPCFacRep, opcodeModPCFacRepExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -874,13 +991,20 @@ namespace MWScript interpreter.installSegment5(opcodeSetDispositionExplicit,new OpSetDisposition<ExplicitRef>); interpreter.installSegment5(opcodeGetDisposition,new OpGetDisposition<ImplicitRef>); interpreter.installSegment5(opcodeGetDispositionExplicit,new OpGetDisposition<ExplicitRef>); - + interpreter.installSegment5 (opcodeGetLevel, new OpGetLevel<ImplicitRef>); interpreter.installSegment5 (opcodeGetLevelExplicit, new OpGetLevel<ExplicitRef>); interpreter.installSegment5 (opcodeSetLevel, new OpSetLevel<ImplicitRef>); interpreter.installSegment5 (opcodeSetLevelExplicit, new OpSetLevel<ExplicitRef>); interpreter.installSegment5 (opcodeGetDeadCount, new OpGetDeadCount); + + interpreter.installSegment3 (opcodeGetPCFacRep, new OpGetPCFacRep<ImplicitRef>); + interpreter.installSegment3 (opcodeGetPCFacRepExplicit, new OpGetPCFacRep<ExplicitRef>); + interpreter.installSegment3 (opcodeSetPCFacRep, new OpSetPCFacRep<ImplicitRef>); + interpreter.installSegment3 (opcodeSetPCFacRepExplicit, new OpSetPCFacRep<ExplicitRef>); + interpreter.installSegment3 (opcodeModPCFacRep, new OpModPCFacRep<ImplicitRef>); + interpreter.installSegment3 (opcodeModPCFacRepExplicit, new OpModPCFacRep<ExplicitRef>); } } } From 5f7d349126c77a61d9152293744d60e0d88a420f Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Wed, 14 Nov 2012 05:32:23 +0100 Subject: [PATCH 228/255] several missing includes --- apps/launcher/model/datafilesmodel.cpp | 2 ++ apps/openmw/mwsound/ffmpeg_decoder.cpp | 5 +++++ components/esm/loadmgef.cpp | 2 ++ 3 files changed, 9 insertions(+) diff --git a/apps/launcher/model/datafilesmodel.cpp b/apps/launcher/model/datafilesmodel.cpp index 47811dcaf0..d85a15e73a 100644 --- a/apps/launcher/model/datafilesmodel.cpp +++ b/apps/launcher/model/datafilesmodel.cpp @@ -2,6 +2,8 @@ #include <QFileInfo> #include <QDir> +#include <stdexcept> + #include <components/esm/esmreader.hpp> #include "esm/esmfile.hpp" diff --git a/apps/openmw/mwsound/ffmpeg_decoder.cpp b/apps/openmw/mwsound/ffmpeg_decoder.cpp index 9298bf8488..a2cccfd13b 100644 --- a/apps/openmw/mwsound/ffmpeg_decoder.cpp +++ b/apps/openmw/mwsound/ffmpeg_decoder.cpp @@ -1,7 +1,12 @@ #ifdef OPENMW_USE_FFMPEG + #include "ffmpeg_decoder.hpp" +// auto_ptr +#include <memory> + +#include <stdexcept> namespace MWSound { diff --git a/components/esm/loadmgef.cpp b/components/esm/loadmgef.cpp index d0230e3b6a..4aef97838a 100644 --- a/components/esm/loadmgef.cpp +++ b/components/esm/loadmgef.cpp @@ -1,5 +1,7 @@ #include "loadmgef.hpp" +#include <stdexcept> + #include <boost/lexical_cast.hpp> #include "esmreader.hpp" From 850606cc30eb77daac374b4842957c9f813015be Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Wed, 14 Nov 2012 18:14:20 +0100 Subject: [PATCH 229/255] Feature #391 AiPackage classes --- openmw/apps/openmw/mwmechanics/aiescort.cpp | 56 +++++++++++++++++++++ openmw/apps/openmw/mwmechanics/aiescort.hpp | 41 +++++++++++++++ openmw/apps/openmw/mwmechanics/aifallow.cpp | 27 ++++++++++ openmw/apps/openmw/mwmechanics/aifallow.hpp | 36 +++++++++++++ openmw/apps/openmw/mwmechanics/aitravel.cpp | 44 ++++++++++++++++ openmw/apps/openmw/mwmechanics/aitravel.hpp | 37 ++++++++++++++ openmw/apps/openmw/mwmechanics/aiwander.cpp | 55 ++++++++++++++++++++ openmw/apps/openmw/mwmechanics/aiwander.hpp | 42 ++++++++++++++++ 8 files changed, 338 insertions(+) create mode 100644 openmw/apps/openmw/mwmechanics/aiescort.cpp create mode 100644 openmw/apps/openmw/mwmechanics/aiescort.hpp create mode 100644 openmw/apps/openmw/mwmechanics/aifallow.cpp create mode 100644 openmw/apps/openmw/mwmechanics/aifallow.hpp create mode 100644 openmw/apps/openmw/mwmechanics/aitravel.cpp create mode 100644 openmw/apps/openmw/mwmechanics/aitravel.hpp create mode 100644 openmw/apps/openmw/mwmechanics/aiwander.cpp create mode 100644 openmw/apps/openmw/mwmechanics/aiwander.hpp diff --git a/openmw/apps/openmw/mwmechanics/aiescort.cpp b/openmw/apps/openmw/mwmechanics/aiescort.cpp new file mode 100644 index 0000000000..eac5d3bf5f --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aiescort.cpp @@ -0,0 +1,56 @@ +#include "aiescort.hpp" + + +MWMechanics::AiEscort::AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset) +{ + mActorID = ActorID; + mDuration = Duration; + mX = X; + mY = Y; + mZ = Z; + mReset = Reset; + +} +MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const +{ + AiEscort * temp = new AiEscort(*this); + return temp; +} + +bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiEscort complted. \n"; + return true; +} + +int MWMechanics::AiEscort::getTypeId() const +{ + return 2; +} + +float MWMechanics::AiEscort::getX() +{ + return mX; +} +float MWMechanics::AiEscort::getY() +{ + return mY; +} +float MWMechanics::AiEscort::getZ() +{ + return mZ; +} +bool MWMechanics::AiEscort::getReset() +{ + return mReset; +} + +std::string MWMechanics::AiEscort::getActorID() +{ + return mActorID; +} + +int MWMechanics::AiEscort::getDuration() +{ + return mDuration; +} diff --git a/openmw/apps/openmw/mwmechanics/aiescort.hpp b/openmw/apps/openmw/mwmechanics/aiescort.hpp new file mode 100644 index 0000000000..cc6a1ec297 --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aiescort.hpp @@ -0,0 +1,41 @@ +#ifndef AIESCORT_H +#define AIESCORT_H + +#include "aipackage.hpp" +#include <iostream> +#include <vector> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ +class AiEscort : public AiPackage +{ + public: + AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset = false); + virtual AiEscort *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + + virtual int getTypeId() const; + float getX(); + float getY(); + float getZ(); + bool getReset(); + std::string getActorID(); + int getDuration(); + + private: + std::string mActorID; + float mX; + float mY; + float mZ; + int mDuration; + bool mReset; +}; +} +#endif // AIESCORT_H diff --git a/openmw/apps/openmw/mwmechanics/aifallow.cpp b/openmw/apps/openmw/mwmechanics/aifallow.cpp new file mode 100644 index 0000000000..2ba5277618 --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aifallow.cpp @@ -0,0 +1,27 @@ +#include "aifallow.hpp" + +MWMechanics::AiFallow::AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset) +{ + mActorID = ActorID; + mDuration = duration; + mX = X; + mY = Y; + mZ = Z; + mReset = Reset; +} +MWMechanics::AiFallow *MWMechanics::AiFallow::clone() const +{ + AiFallow * temp = new AiFallow(*this); + return temp; +} + + bool MWMechanics::AiFallow::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiFallow complited. \n"; + return true; +} + + int MWMechanics::AiFallow::getTypeId() const +{ + return 3; +} diff --git a/openmw/apps/openmw/mwmechanics/aifallow.hpp b/openmw/apps/openmw/mwmechanics/aifallow.hpp new file mode 100644 index 0000000000..b602bf300f --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aifallow.hpp @@ -0,0 +1,36 @@ +#ifndef AIFALLOW_H +#define AIFALLOW_H + +#include "aipackage.hpp" +#include <string> +#include <iostream> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ + +class AiFallow : AiPackage +{ + public: + AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset = false); + virtual AiFallow *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + + virtual int getTypeId() const; + ///< 0: Wanter, 1 Travel, 2 Escort, 3 Follo + private: + float mDuration; + float mX; + float mY; + float mZ; + bool mReset; + std::string mActorID; +}; +} +#endif // AIFALLOW_H diff --git a/openmw/apps/openmw/mwmechanics/aitravel.cpp b/openmw/apps/openmw/mwmechanics/aitravel.cpp new file mode 100644 index 0000000000..a71c857834 --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aitravel.cpp @@ -0,0 +1,44 @@ +#include "aitravel.hpp" + +MWMechanics::AiTravel::AiTravel(float x, float y, float z, bool reset) +{ + mX = x; + mY = y; + mZ = z; + mReset = reset; +} +MWMechanics::AiTravel * MWMechanics::AiTravel::clone() const +{ + AiTravel * temp = new AiTravel(*this); + return temp; +} +bool MWMechanics::AiTravel::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiTravel complited. \n"; + return true; +} +int MWMechanics::AiTravel::getTypeId() const +{ + return 1; +} + +float MWMechanics::AiTravel::getX() +{ + return mX; +} + + +float MWMechanics::AiTravel::getY() +{ + return mY; +} + +float MWMechanics::AiTravel::getZ() +{ + return mZ; +} + +bool MWMechanics::AiTravel::getReset() +{ + return mReset; +} diff --git a/openmw/apps/openmw/mwmechanics/aitravel.hpp b/openmw/apps/openmw/mwmechanics/aitravel.hpp new file mode 100644 index 0000000000..0503935fd4 --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aitravel.hpp @@ -0,0 +1,37 @@ +#ifndef AITRAVEL_HPP_INCLUDED +#define AITRAVEL_HPP_INCLUDED + +#include "aipackage.hpp" +#include <iostream> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ +class AiTravel : public AiPackage +{ + public: + AiTravel(float x, float y, float z, bool reset = false); + virtual AiTravel *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + + virtual int getTypeId() const; + float getX(); + float getY(); + float getZ(); + bool getReset(); + + private: + float mX; + float mY; + float mZ; + bool mReset; +}; +} + +#endif // AITRAVEL_HPP_INCLUDED diff --git a/openmw/apps/openmw/mwmechanics/aiwander.cpp b/openmw/apps/openmw/mwmechanics/aiwander.cpp new file mode 100644 index 0000000000..b77b2c04bc --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aiwander.cpp @@ -0,0 +1,55 @@ +#include "aiwander.hpp" + +MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset) +{ + mDistance = distance; + mDuration = duration; + mTimeOfDay = timeOfDay; + mIdle = Idle; + mReset = reset; +} + +int MWMechanics::AiWander::getDistance() const +{ + return mDistance; +} + +int MWMechanics::AiWander::getDuration() const +{ + return mDuration; +} + +int MWMechanics::AiWander::getTimeOfDay() const +{ + return mTimeOfDay; +} + +bool MWMechanics::AiWander::getReset() const +{ + return mReset; +} + +MWMechanics::AiPackage * MWMechanics::AiWander::clone() const +{ + return new AiWander(*this); +} + +bool MWMechanics::AiWander::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiWadner complited. \n"; + return true; +} + +int MWMechanics::AiWander::getTypeId() const +{ + return 0; +} + +int MWMechanics::AiWander::getIdle(int index) const +{ + if(index < 0 || (uint)index > mIdle.size()) + return -1; + int temp; + temp = mIdle.at(index); + return temp; +} diff --git a/openmw/apps/openmw/mwmechanics/aiwander.hpp b/openmw/apps/openmw/mwmechanics/aiwander.hpp new file mode 100644 index 0000000000..6ecd7f1008 --- /dev/null +++ b/openmw/apps/openmw/mwmechanics/aiwander.hpp @@ -0,0 +1,42 @@ +#ifndef AIWANDER_H +#define AIWANDER_H + +#include "aipackage.hpp" +#include <iostream> +#include <vector> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ + +class AiWander : public AiPackage +{ +public: + + AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset=false); + virtual AiPackage *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; + ///< 0: Wander + + int getDistance() const; + int getDuration()const; + int getTimeOfDay()const; + bool getReset()const; + int getIdle(int index) const; + +private: + int mDistance; + int mDuration; + int mTimeOfDay; + std::vector<int> mIdle; + bool mReset; +}; +} + +#endif // AIWANDER_H From c26d17c74b4b38c3472c184fc7b2b0c8b1675391 Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Wed, 14 Nov 2012 18:14:59 +0100 Subject: [PATCH 230/255] Feature #391 AiPackage classes --- openmw/apps/openmw/CMakeLists.txt | 132 ++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 openmw/apps/openmw/CMakeLists.txt diff --git a/openmw/apps/openmw/CMakeLists.txt b/openmw/apps/openmw/CMakeLists.txt new file mode 100644 index 0000000000..cdfbcc27db --- /dev/null +++ b/openmw/apps/openmw/CMakeLists.txt @@ -0,0 +1,132 @@ + +# config file +configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/config.hpp") + +# local files +set(GAME + main.cpp + engine.cpp +) +set(GAME_HEADER + engine.hpp + config.hpp +) +source_group(game FILES ${GAME} ${GAME_HEADER}) + +add_openmw_dir (mwrender + renderingmanager debugging sky player animation npcanimation creatureanimation actors objects + renderinginterface localmap occlusionquery terrain terrainmaterial water shadows + compositors characterpreview externalrendering globalmap + ) + +add_openmw_dir (mwinput + inputmanagerimp + ) + +add_openmw_dir (mwgui + text_input widgets race class birth review windowmanagerimp console dialogue + dialogue_history window_base stats_window messagebox journalwindow charactercreation + map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list + formatting inventorywindow container hud countdialog tradewindow settingswindow + confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu + itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog + enchantingdialog trainingwindow travelwindow + ) + +add_openmw_dir (mwdialogue + dialoguemanagerimp journalimp journalentry quest topic + ) + +add_openmw_dir (mwscript + locals scriptmanagerimp compilercontext interpretercontext cellextensions miscextensions + guiextensions soundextensions skyextensions statsextensions containerextensions + aiextensions controlextensions extensions globalscripts ref dialogueextensions + animationextensions transformationextensions consoleextensions userextensions + ) + +add_openmw_dir (mwsound + soundmanagerimp openal_output audiere_decoder mpgsnd_decoder ffmpeg_decoder + ) + +add_openmw_dir (mwworld + refdata worldimp physicssystem scene globals class action nullaction actionteleport + containerstore actiontalk actiontake manualref player cellfunctors + cells localscripts customdata weather inventorystore ptr actionopen actionread + actionequip timestamp actionalchemy cellstore actionapply actioneat + esmstore store recordcmp + ) + +add_openmw_dir (mwclass + classes activator creature npc weapon armor potion apparatus book clothing container door + ingredient creaturelevlist itemlevlist light lockpick misc probe repair static + ) + +add_openmw_dir (mwmechanics + mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells + activespells npcstats aipackage aisequence alchemy aiwander aitravel aifallow aiescort + ) + +add_openmw_dir (mwbase + environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager + inputmanager windowmanager + ) + +# Main executable +IF(OGRE_STATIC) +IF(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ELSE(WIN32) +ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL) +set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) +ENDIF(WIN32) +ENDIF(OGRE_STATIC) +add_executable(openmw + ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} + ${OPENMW_FILES} + ${GAME} ${GAME_HEADER} + ${APPLE_BUNDLE_RESOURCES} +) + +# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING +# when we change the backend. +include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS}) +add_definitions(${SOUND_DEFINE}) + +target_link_libraries(openmw + ${OGRE_LIBRARIES} + ${OGRE_Terrain_LIBRARY} + ${OGRE_STATIC_PLUGINS} + ${OIS_LIBRARIES} + ${Boost_LIBRARIES} + ${OPENAL_LIBRARY} + ${SOUND_INPUT_LIBRARY} + ${BULLET_LIBRARIES} + ${MYGUI_LIBRARIES} + ${MYGUI_PLATFORM_LIBRARIES} + "shiny" + "shiny.OgrePlatform" + "oics" + components +) + +# Fix for not visible pthreads functions for linker with glibc 2.15 +if (UNIX AND NOT APPLE) +target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) +endif() + +if(APPLE) + find_library(CARBON_FRAMEWORK Carbon) + find_library(COCOA_FRAMEWORK Cocoa) + find_library(IOKIT_FRAMEWORK IOKit) + target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) +endif(APPLE) + +if(DPKG_PROGRAM) + INSTALL(TARGETS openmw RUNTIME DESTINATION games COMPONENT openmw) +endif(DPKG_PROGRAM) + +if (BUILD_WITH_CODE_COVERAGE) + add_definitions (--coverage) + target_link_libraries(openmw gcov) +endif() From 698afbec3e62f54ee44b76ae02e07ca5beaa164b Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Wed, 14 Nov 2012 18:40:32 +0100 Subject: [PATCH 231/255] Feature #391 Dummy AI package classes --- apps/openmw/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index b9ce26a661..cdfbcc27db 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -63,7 +63,7 @@ add_openmw_dir (mwclass add_openmw_dir (mwmechanics mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells - activespells npcstats aipackage aisequence alchemy + activespells npcstats aipackage aisequence alchemy aiwander aitravel aifallow aiescort ) add_openmw_dir (mwbase From e6c8e1f0d7e2149de4d980d617e504971aaa29ae Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Wed, 14 Nov 2012 18:42:04 +0100 Subject: [PATCH 232/255] Feature #391 Dummy AI package classes --- apps/openmw/mwmechanics/aiescort.cpp | 56 ++++++++++++++++++++++++++++ apps/openmw/mwmechanics/aiescort.hpp | 41 ++++++++++++++++++++ apps/openmw/mwmechanics/aifallow.cpp | 27 ++++++++++++++ apps/openmw/mwmechanics/aifallow.hpp | 36 ++++++++++++++++++ apps/openmw/mwmechanics/aitravel.cpp | 44 ++++++++++++++++++++++ apps/openmw/mwmechanics/aitravel.hpp | 37 ++++++++++++++++++ apps/openmw/mwmechanics/aiwander.cpp | 55 +++++++++++++++++++++++++++ apps/openmw/mwmechanics/aiwander.hpp | 42 +++++++++++++++++++++ 8 files changed, 338 insertions(+) create mode 100644 apps/openmw/mwmechanics/aiescort.cpp create mode 100644 apps/openmw/mwmechanics/aiescort.hpp create mode 100644 apps/openmw/mwmechanics/aifallow.cpp create mode 100644 apps/openmw/mwmechanics/aifallow.hpp create mode 100644 apps/openmw/mwmechanics/aitravel.cpp create mode 100644 apps/openmw/mwmechanics/aitravel.hpp create mode 100644 apps/openmw/mwmechanics/aiwander.cpp create mode 100644 apps/openmw/mwmechanics/aiwander.hpp diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp new file mode 100644 index 0000000000..eac5d3bf5f --- /dev/null +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -0,0 +1,56 @@ +#include "aiescort.hpp" + + +MWMechanics::AiEscort::AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset) +{ + mActorID = ActorID; + mDuration = Duration; + mX = X; + mY = Y; + mZ = Z; + mReset = Reset; + +} +MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const +{ + AiEscort * temp = new AiEscort(*this); + return temp; +} + +bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiEscort complted. \n"; + return true; +} + +int MWMechanics::AiEscort::getTypeId() const +{ + return 2; +} + +float MWMechanics::AiEscort::getX() +{ + return mX; +} +float MWMechanics::AiEscort::getY() +{ + return mY; +} +float MWMechanics::AiEscort::getZ() +{ + return mZ; +} +bool MWMechanics::AiEscort::getReset() +{ + return mReset; +} + +std::string MWMechanics::AiEscort::getActorID() +{ + return mActorID; +} + +int MWMechanics::AiEscort::getDuration() +{ + return mDuration; +} diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp new file mode 100644 index 0000000000..cc6a1ec297 --- /dev/null +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -0,0 +1,41 @@ +#ifndef AIESCORT_H +#define AIESCORT_H + +#include "aipackage.hpp" +#include <iostream> +#include <vector> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ +class AiEscort : public AiPackage +{ + public: + AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset = false); + virtual AiEscort *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + + virtual int getTypeId() const; + float getX(); + float getY(); + float getZ(); + bool getReset(); + std::string getActorID(); + int getDuration(); + + private: + std::string mActorID; + float mX; + float mY; + float mZ; + int mDuration; + bool mReset; +}; +} +#endif // AIESCORT_H diff --git a/apps/openmw/mwmechanics/aifallow.cpp b/apps/openmw/mwmechanics/aifallow.cpp new file mode 100644 index 0000000000..2ba5277618 --- /dev/null +++ b/apps/openmw/mwmechanics/aifallow.cpp @@ -0,0 +1,27 @@ +#include "aifallow.hpp" + +MWMechanics::AiFallow::AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset) +{ + mActorID = ActorID; + mDuration = duration; + mX = X; + mY = Y; + mZ = Z; + mReset = Reset; +} +MWMechanics::AiFallow *MWMechanics::AiFallow::clone() const +{ + AiFallow * temp = new AiFallow(*this); + return temp; +} + + bool MWMechanics::AiFallow::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiFallow complited. \n"; + return true; +} + + int MWMechanics::AiFallow::getTypeId() const +{ + return 3; +} diff --git a/apps/openmw/mwmechanics/aifallow.hpp b/apps/openmw/mwmechanics/aifallow.hpp new file mode 100644 index 0000000000..b602bf300f --- /dev/null +++ b/apps/openmw/mwmechanics/aifallow.hpp @@ -0,0 +1,36 @@ +#ifndef AIFALLOW_H +#define AIFALLOW_H + +#include "aipackage.hpp" +#include <string> +#include <iostream> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ + +class AiFallow : AiPackage +{ + public: + AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset = false); + virtual AiFallow *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + + virtual int getTypeId() const; + ///< 0: Wanter, 1 Travel, 2 Escort, 3 Follo + private: + float mDuration; + float mX; + float mY; + float mZ; + bool mReset; + std::string mActorID; +}; +} +#endif // AIFALLOW_H diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp new file mode 100644 index 0000000000..a71c857834 --- /dev/null +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -0,0 +1,44 @@ +#include "aitravel.hpp" + +MWMechanics::AiTravel::AiTravel(float x, float y, float z, bool reset) +{ + mX = x; + mY = y; + mZ = z; + mReset = reset; +} +MWMechanics::AiTravel * MWMechanics::AiTravel::clone() const +{ + AiTravel * temp = new AiTravel(*this); + return temp; +} +bool MWMechanics::AiTravel::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiTravel complited. \n"; + return true; +} +int MWMechanics::AiTravel::getTypeId() const +{ + return 1; +} + +float MWMechanics::AiTravel::getX() +{ + return mX; +} + + +float MWMechanics::AiTravel::getY() +{ + return mY; +} + +float MWMechanics::AiTravel::getZ() +{ + return mZ; +} + +bool MWMechanics::AiTravel::getReset() +{ + return mReset; +} diff --git a/apps/openmw/mwmechanics/aitravel.hpp b/apps/openmw/mwmechanics/aitravel.hpp new file mode 100644 index 0000000000..0503935fd4 --- /dev/null +++ b/apps/openmw/mwmechanics/aitravel.hpp @@ -0,0 +1,37 @@ +#ifndef AITRAVEL_HPP_INCLUDED +#define AITRAVEL_HPP_INCLUDED + +#include "aipackage.hpp" +#include <iostream> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ +class AiTravel : public AiPackage +{ + public: + AiTravel(float x, float y, float z, bool reset = false); + virtual AiTravel *clone() const; + + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + + virtual int getTypeId() const; + float getX(); + float getY(); + float getZ(); + bool getReset(); + + private: + float mX; + float mY; + float mZ; + bool mReset; +}; +} + +#endif // AITRAVEL_HPP_INCLUDED diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp new file mode 100644 index 0000000000..b77b2c04bc --- /dev/null +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -0,0 +1,55 @@ +#include "aiwander.hpp" + +MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset) +{ + mDistance = distance; + mDuration = duration; + mTimeOfDay = timeOfDay; + mIdle = Idle; + mReset = reset; +} + +int MWMechanics::AiWander::getDistance() const +{ + return mDistance; +} + +int MWMechanics::AiWander::getDuration() const +{ + return mDuration; +} + +int MWMechanics::AiWander::getTimeOfDay() const +{ + return mTimeOfDay; +} + +bool MWMechanics::AiWander::getReset() const +{ + return mReset; +} + +MWMechanics::AiPackage * MWMechanics::AiWander::clone() const +{ + return new AiWander(*this); +} + +bool MWMechanics::AiWander::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiWadner complited. \n"; + return true; +} + +int MWMechanics::AiWander::getTypeId() const +{ + return 0; +} + +int MWMechanics::AiWander::getIdle(int index) const +{ + if(index < 0 || (uint)index > mIdle.size()) + return -1; + int temp; + temp = mIdle.at(index); + return temp; +} diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp new file mode 100644 index 0000000000..6ecd7f1008 --- /dev/null +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -0,0 +1,42 @@ +#ifndef AIWANDER_H +#define AIWANDER_H + +#include "aipackage.hpp" +#include <iostream> +#include <vector> + +namespace MWWorld +{ +class Ptr; +} + +namespace MWMechanics +{ + +class AiWander : public AiPackage +{ +public: + + AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset=false); + virtual AiPackage *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; + ///< 0: Wander + + int getDistance() const; + int getDuration()const; + int getTimeOfDay()const; + bool getReset()const; + int getIdle(int index) const; + +private: + int mDistance; + int mDuration; + int mTimeOfDay; + std::vector<int> mIdle; + bool mReset; +}; +} + +#endif // AIWANDER_H From 9669eed083f6e3346024fa1e122b56279aa5d1e8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 15 Nov 2012 20:00:27 +0100 Subject: [PATCH 233/255] Issue #219: added last missing function filters --- apps/openmw/mwdialogue/filter.cpp | 226 +++++++++++++++------- apps/openmw/mwdialogue/selectwrapper.cpp | 70 ++++--- apps/openmw/mwdialogue/selectwrapper.hpp | 36 ++-- apps/openmw/mwmechanics/creaturestats.cpp | 76 ++++++-- apps/openmw/mwmechanics/creaturestats.hpp | 35 +++- apps/openmw/mwmechanics/npcstats.cpp | 34 +++- apps/openmw/mwmechanics/npcstats.hpp | 28 ++- apps/openmw/mwworld/class.cpp | 5 + apps/openmw/mwworld/class.hpp | 5 + 9 files changed, 349 insertions(+), 166 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 21904b4bc2..0deef7fd03 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -74,7 +74,7 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const if (iter==stats.getFactionRanks().end()) return false; - + // check rank if (iter->second < info.mData.mRank) return false; @@ -87,14 +87,14 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const if (info.mData.mGender==(npc->mBase->mFlags & npc->mBase->Female ? 0 : 1)) return false; } - + return true; } bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const { const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - + // check player faction if (!info.mPcFaction.empty()) { @@ -123,7 +123,7 @@ bool MWDialogue::Filter::testSelectStructs (const ESM::DialInfo& info) const iter != info.mSelects.end(); ++iter) if (!testSelectStruct (*iter)) return false; - + return true; } @@ -131,7 +131,7 @@ bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const { if (select.isNpcOnly() && mActor.getTypeName()!=typeid (ESM::NPC).name()) return select.isInverted(); - + switch (select.getType()) { case SelectWrapper::Type_None: return true; @@ -139,7 +139,7 @@ bool MWDialogue::Filter::testSelectStruct (const SelectWrapper& select) const case SelectWrapper::Type_Numeric: return testSelectStructNumeric (select); case SelectWrapper::Type_Boolean: return select.selectCompare (getSelectStructBoolean (select)); } - + return true; } @@ -148,11 +148,11 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c switch (select.getFunction()) { case SelectWrapper::Function_Global: - + // internally all globals are float :( return select.selectCompare ( MWBase::Environment::get().getWorld()->getGlobalVariable (select.getName()).mFloat); - + case SelectWrapper::Function_Local: { std::string scriptName = MWWorld::Class::get (mActor).getScript (mActor); @@ -178,7 +178,7 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c if (i<script->mData.mNumShorts) return select.selectCompare (static_cast<int> (locals.mShorts[i])); - + i -= script->mData.mNumShorts; if (i<script->mData.mNumLongs) @@ -186,39 +186,39 @@ bool MWDialogue::Filter::testSelectStructNumeric (const SelectWrapper& select) c i -= script->mData.mNumShorts; - return select.selectCompare (locals.mFloats.at (i)); + return select.selectCompare (locals.mFloats.at (i)); } - + case SelectWrapper::Function_PcHealthPercent: { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - - float ratio = MWWorld::Class::get (player).getCreatureStats (player).getHealth().getCurrent() / + + float ratio = MWWorld::Class::get (player).getCreatureStats (player).getHealth().getCurrent() / MWWorld::Class::get (player).getCreatureStats (player).getHealth().getModified(); - + return select.selectCompare (ratio); } - + case SelectWrapper::Function_PcDynamicStat: { MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - + float value = MWWorld::Class::get (player).getCreatureStats (player). - getDynamic (select.getArgument()).getCurrent(); - + getDynamic (select.getArgument()).getCurrent(); + return select.selectCompare (value); } - + case SelectWrapper::Function_HealthPercent: { - float ratio = MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getCurrent() / + float ratio = MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getCurrent() / MWWorld::Class::get (mActor).getCreatureStats (mActor).getHealth().getModified(); - + return select.selectCompare (ratio); } default: - + throw std::runtime_error ("unknown numeric select function"); } } @@ -230,11 +230,11 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con switch (select.getFunction()) { case SelectWrapper::Function_Journal: - + return MWBase::Environment::get().getJournal()->getJournalIndex (select.getName()); - - case SelectWrapper::Function_Item: - { + + case SelectWrapper::Function_Item: + { MWWorld::ContainerStore& store = MWWorld::Class::get (player).getContainerStore (player); int sum = 0; @@ -244,39 +244,39 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con for (MWWorld::ContainerStoreIterator iter (store.begin()); iter!=store.end(); ++iter) if (toLower(iter->getCellRef().mRefID) == name) sum += iter->getRefData().getCount(); - + return sum; } case SelectWrapper::Function_Dead: return MWBase::Environment::get().getMechanicsManager()->countDeaths (select.getName()); - + case SelectWrapper::Function_Choice: - + return mChoice; - + case SelectWrapper::Function_AiSetting: - + return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAiSetting (select.getArgument()); - + case SelectWrapper::Function_PcAttribute: - + return MWWorld::Class::get (player).getCreatureStats (player). getAttribute (select.getArgument()).getModified(); case SelectWrapper::Function_PcSkill: - + return static_cast<int> (MWWorld::Class::get (player). getNpcStats (player).getSkill (select.getArgument()).getModified()); - + case SelectWrapper::Function_FriendlyHit: { int hits = MWWorld::Class::get (mActor).getCreatureStats (mActor).getFriendlyHits(); - return hits>4 ? 4 : hits; + return hits>4 ? 4 : hits; } - + case SelectWrapper::Function_PcLevel: return MWWorld::Class::get (player).getCreatureStats (player).getLevel(); @@ -284,26 +284,26 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con case SelectWrapper::Function_PcGender: return player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female ? 0 : 1; - + case SelectWrapper::Function_PcClothingModifier: { MWWorld::InventoryStore& store = MWWorld::Class::get (player).getInventoryStore (player); int value = 0; - + for (int i=0; i<=15; ++i) // everything except thigns held in hands and amunition { MWWorld::ContainerStoreIterator slot = store.getSlot (i); - + if (slot!=store.end()) value += MWWorld::Class::get (*slot).getValue (*slot); } - + return value; } - + case SelectWrapper::Function_PcCrimeLevel: - + return MWWorld::Class::get (player).getNpcStats (player).getBounty(); case SelectWrapper::Function_RankRequirement: @@ -313,12 +313,12 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con std::string faction = MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first; - + int rank = getFactionRank (player, faction); - + if (rank>=9) return 0; // max rank - + int result = 0; if (hasFactionRankSkillRequirements (player, faction, rank+1)) @@ -328,16 +328,68 @@ int MWDialogue::Filter::getSelectStructInteger (const SelectWrapper& select) con result += 2; return result; - } - + } + case SelectWrapper::Function_Level: - + return MWWorld::Class::get (mActor).getCreatureStats (mActor).getLevel(); - + case SelectWrapper::Function_PCReputation: - - return MWWorld::Class::get (player).getNpcStats (player).getReputation(); - + + return MWWorld::Class::get (player).getNpcStats (player).getReputation(); + + case SelectWrapper::Function_Weather: + + return MWBase::Environment::get().getWorld()->getCurrentWeather(); + + case SelectWrapper::Function_Reputation: + + return MWWorld::Class::get (mActor).getNpcStats (mActor).getReputation(); + + case SelectWrapper::Function_FactionRankDiff: + { + if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty()) + return 0; + + std::pair<std::string, int> faction = + *MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin(); + + int rank = getFactionRank (player, faction.first); + + return rank-faction.second; + } + + case SelectWrapper::Function_WerewolfKills: + + return MWWorld::Class::get (player).getNpcStats (player).getWerewolfKills(); + + case SelectWrapper::Function_RankLow: + case SelectWrapper::Function_RankHigh: + { + bool low = select.getFunction()==SelectWrapper::Function_RankLow; + + if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty()) + return 0; + + std::string factionId = + MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first; + + int value = 0; + + const ESM::Faction& faction = + *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId); + + MWMechanics::NpcStats& playerStats = MWWorld::Class::get (player).getNpcStats (player); + + for (std::vector<ESM::Faction::Reaction>::const_iterator iter (faction.mReactions.begin()); + iter!=faction.mReactions.end(); ++iter) + if (playerStats.getFactionRanks().find (iter->mFaction)!=playerStats.getFactionRanks().end()) + if (low ? iter->mReaction<value : iter->mReaction>value) + value = iter->mReaction; + + return value; + } + default: throw std::runtime_error ("unknown integer select function"); @@ -351,13 +403,13 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co switch (select.getFunction()) { case SelectWrapper::Function_False: - + return false; - + case SelectWrapper::Function_Id: - + return select.getName()==toLower (MWWorld::Class::get (mActor).getId (mActor)); - + case SelectWrapper::Function_Faction: return toLower (mActor.get<ESM::NPC>()->mBase->mFaction)==select.getName(); @@ -371,9 +423,9 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return toLower (mActor.get<ESM::NPC>()->mBase->mRace)==select.getName(); case SelectWrapper::Function_Cell: - + return toLower (mActor.getCell()->mCell->mName)==select.getName(); - + case SelectWrapper::Function_SameGender: return (player.get<ESM::NPC>()->mBase->mFlags & ESM::NPC::Female)== @@ -383,46 +435,70 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co return toLower (mActor.get<ESM::NPC>()->mBase->mRace)!= toLower (player.get<ESM::NPC>()->mBase->mRace); - + case SelectWrapper::Function_SameFaction: return MWWorld::Class::get (mActor).getNpcStats (mActor).isSameFaction ( MWWorld::Class::get (player).getNpcStats (player)); - + case SelectWrapper::Function_PcCommonDisease: return MWWorld::Class::get (player).getCreatureStats (player).hasCommonDisease(); - + case SelectWrapper::Function_PcBlightDisease: return MWWorld::Class::get (player).getCreatureStats (player).hasBlightDisease(); - + case SelectWrapper::Function_PcCorprus: - + return MWWorld::Class::get (player).getCreatureStats (player). getMagicEffects().get (132).mMagnitude!=0; - + case SelectWrapper::Function_PcExpelled: { if (MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().empty()) return false; - + std::string faction = MWWorld::Class::get (mActor).getNpcStats (mActor).getFactionRanks().begin()->first; - + std::set<std::string>& expelled = MWWorld::Class::get (player).getNpcStats (player).getExpelled(); - + return expelled.find (faction)!=expelled.end(); } - + case SelectWrapper::Function_PcVampire: - + return MWWorld::Class::get (player).getNpcStats (player).isVampire(); - + case SelectWrapper::Function_TalkedToPc: - + return mTalkedToPlayer; + case SelectWrapper::Function_Alarmed: + + return MWWorld::Class::get (mActor).getCreatureStats (mActor).isAlarmed(); + + case SelectWrapper::Function_Detected: + + return MWWorld::Class::get (mActor).hasDetected (mActor, player); + + case SelectWrapper::Function_Attacked: + + return MWWorld::Class::get (mActor).getCreatureStats (mActor).getAttacked(); + + case SelectWrapper::Function_ShouldAttack: + + return MWWorld::Class::get (mActor).getCreatureStats (mActor).isHostile(); + + case SelectWrapper::Function_CreatureTargetted: + + return MWWorld::Class::get (mActor).getCreatureStats (mActor).getCreatureTargetted(); + + case SelectWrapper::Function_PCWerewolf: + + return MWWorld::Class::get (player).getNpcStats (player).isWerewolf(); + default: throw std::runtime_error ("unknown boolean select function"); @@ -432,12 +508,12 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co int MWDialogue::Filter::getFactionRank (const MWWorld::Ptr& actor, const std::string& factionId) const { MWMechanics::NpcStats& stats = MWWorld::Class::get (actor).getNpcStats (actor); - + std::map<std::string, int>::const_iterator iter = stats.getFactionRanks().find (factionId); - + if (iter==stats.getFactionRanks().end()) return -1; - + return iter->second; } diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index ae5b8c582f..bba17bfd10 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -34,7 +34,7 @@ namespace throw std::runtime_error ("unknown compare type in dialogue info select"); } - + template<typename T> bool selectCompareImp (const ESM::DialInfo::SelectStruct& select, T value1) { @@ -49,21 +49,22 @@ namespace } else throw std::runtime_error ( - "unsupported variable type in dialogue info select"); + "unsupported variable type in dialogue info select"); } } MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() const { int index = 0; - + std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index; switch (index) { - // 0, 1 + case 0: return Function_RankLow; + case 1: return Function_RankHigh; case 2: return Function_RankRequirement; - // 3 + case 3: return Function_Reputation; case 4: return Function_HealthPercent; case 5: return Function_PCReputation; case 6: return Function_PcLevel; @@ -82,22 +83,26 @@ MWDialogue::SelectWrapper::Function MWDialogue::SelectWrapper::decodeFunction() case 44: return Function_SameGender; case 45: return Function_SameRace; case 46: return Function_SameFaction; - // 47-49 + case 47: return Function_FactionRankDiff; + case 48: return Function_Detected; + case 49: return Function_Alarmed; case 50: return Function_Choice; case 51: case 52: case 53: case 54: case 55: case 56: case 57: return Function_PcAttribute; case 58: return Function_PcCorprus; - // 59 + case 59: return Function_Weather; case 60: return Function_PcVampire; case 61: return Function_Level; - // 62 + case 62: return Function_Attacked; case 63: return Function_TalkedToPc; case 64: return Function_PcDynamicStat; - // 65 + case 65: return Function_CreatureTargetted; case 66: return Function_FriendlyHit; case 67: case 68: case 69: case 70: return Function_AiSetting; - // 71 + case 71: return Function_ShouldAttack; + case 72: return Function_PCWerewolf; + case 73: return Function_WerewolfKills; } - + return Function_False; } @@ -130,11 +135,11 @@ int MWDialogue::SelectWrapper::getArgument() const { if (mSelect.mSelectRule[1]!='1') return 0; - + int index = 0; - + std::istringstream (mSelect.mSelectRule.substr(2,2)) >> index; - + switch (index) { // AI settings @@ -142,7 +147,7 @@ int MWDialogue::SelectWrapper::getArgument() const case 68: return 0; case 69: return 3; case 70: return 2; - + // attributes case 10: return 0; case 51: return 1; @@ -152,7 +157,7 @@ int MWDialogue::SelectWrapper::getArgument() const case 55: return 5; case 56: return 6; case 57: return 7; - + // skills case 11: return 0; case 12: return 1; @@ -181,13 +186,13 @@ int MWDialogue::SelectWrapper::getArgument() const case 35: return 24; case 36: return 25; case 37: return 26; - + // dynamic stats case 8: return 1; case 9: return 2; case 64: return 0; } - + return 0; } @@ -204,17 +209,21 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_PcCrimeLevel, Function_RankRequirement, Function_Level, Function_PCReputation, + Function_Weather, + Function_Reputation, Function_FactionRankDiff, + Function_WerewolfKills, + Function_RankLow, Function_RankHigh, Function_None // end marker }; - + static const Function numericFunctions[] = { Function_Global, Function_Local, Function_PcDynamicStat, Function_PcHealthPercent, Function_HealthPercent, Function_None // end marker - }; - + }; + static const Function booleanFunctions[] = { Function_False, @@ -223,15 +232,19 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const Function_PcCommonDisease, Function_PcBlightDisease, Function_PcCorprus, Function_PcExpelled, Function_PcVampire, Function_TalkedToPc, + Function_Alarmed, Function_Detected, + Function_Attacked, Function_ShouldAttack, + Function_CreatureTargetted, + Function_PCWerewolf, Function_None // end marker - }; - + }; + Function function = getFunction(); for (int i=0; integerFunctions[i]!=Function_None; ++i) if (integerFunctions[i]==function) return Type_Integer; - + for (int i=0; numericFunctions[i]!=Function_None; ++i) if (numericFunctions[i]==function) return Type_Numeric; @@ -239,7 +252,7 @@ MWDialogue::SelectWrapper::Type MWDialogue::SelectWrapper::getType() const for (int i=0; booleanFunctions[i]!=Function_None; ++i) if (booleanFunctions[i]==function) return Type_Boolean; - + return Type_None; } @@ -261,15 +274,18 @@ bool MWDialogue::SelectWrapper::isNpcOnly() const Function_PcVampire, Function_PcCrimeLevel, Function_RankRequirement, + Function_Reputation, Function_FactionRankDiff, + Function_PCWerewolf, Function_WerewolfKills, + Function_RankLow, Function_RankHigh, Function_None // end marker }; Function function = getFunction(); - + for (int i=0; functions[i]!=Function_None; ++i) if (functions[i]==function) return true; - + return false; } diff --git a/apps/openmw/mwdialogue/selectwrapper.hpp b/apps/openmw/mwdialogue/selectwrapper.hpp index 15cd5bfff9..b77ed7985a 100644 --- a/apps/openmw/mwdialogue/selectwrapper.hpp +++ b/apps/openmw/mwdialogue/selectwrapper.hpp @@ -8,9 +8,9 @@ namespace MWDialogue class SelectWrapper { const ESM::DialInfo::SelectStruct& mSelect; - + public: - + enum Function { Function_None, Function_False, @@ -36,7 +36,13 @@ namespace MWDialogue Function_PcLevel, Function_PcHealthPercent, Function_PcDynamicStat, Function_PcGender, Function_PcClothingModifier, Function_PcCrimeLevel, Function_RankRequirement, - Function_HealthPercent, Function_Level, Function_PCReputation + Function_HealthPercent, Function_Level, Function_PCReputation, + Function_Weather, + Function_Reputation, Function_Alarmed, Function_FactionRankDiff, Function_Detected, + Function_Attacked, Function_ShouldAttack, + Function_CreatureTargetted, + Function_PCWerewolf, Function_WerewolfKills, + Function_RankLow, Function_RankHigh }; enum Type @@ -46,32 +52,32 @@ namespace MWDialogue Type_Numeric, Type_Boolean }; - + private: - + Function decodeFunction() const; - + public: - + SelectWrapper (const ESM::DialInfo::SelectStruct& select); - + Function getFunction() const; - + int getArgument() const; - + Type getType() const; - + bool isInverted() const; - + bool isNpcOnly() const; ///< \attention Do not call any of the select functions for this select struct! - + bool selectCompare (int value) const; bool selectCompare (float value) const; - + bool selectCompare (bool value) const; - + std::string getName() const; ///< Return case-smashed name. }; diff --git a/apps/openmw/mwmechanics/creaturestats.cpp b/apps/openmw/mwmechanics/creaturestats.cpp index 9ee7ca7c27..4be5d55b22 100644 --- a/apps/openmw/mwmechanics/creaturestats.cpp +++ b/apps/openmw/mwmechanics/creaturestats.cpp @@ -8,9 +8,10 @@ #include "../mwbase/world.hpp" namespace MWMechanics -{ +{ CreatureStats::CreatureStats() - : mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false) + : mLevel (0), mLevelHealthBonus(0.f), mDead (false), mFriendlyHits (0), mTalkedTo (false), mAlarmed (false), + mAttacked (false), mHostile (false) { for (int i=0; i<4; ++i) mAiSettings[i] = 0; @@ -30,26 +31,26 @@ namespace MWMechanics { return mAiSequence; } - + AiSequence& CreatureStats::getAiSequence() { - return mAiSequence; + return mAiSequence; } - - float CreatureStats::getFatigueTerm() const + + float CreatureStats::getFatigueTerm() const { int max = getFatigue().getModified(); int current = getFatigue().getCurrent(); - + float normalised = max==0 ? 1 : std::max (0.0f, static_cast<float> (current)/max); const MWWorld::Store<ESM::GameSetting> &gmst = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>(); - + return gmst.find ("fFatigueBase")->getFloat() - gmst.find ("fFatigueMult")->getFloat() * (1-normalised); } - + const Stat<int> &CreatureStats::getAttribute(int index) const { if (index < 0 || index > 7) { @@ -92,13 +93,13 @@ namespace MWMechanics { return mLevel; } - + int CreatureStats::getAiSetting (int index) const { assert (index>=0 && index<4); return mAiSettings[index]; } - + Stat<int> &CreatureStats::getAttribute(int index) { if (index < 0 || index > 7) { @@ -168,7 +169,7 @@ namespace MWMechanics if (index==0 && mDynamic[index].getCurrent()<1) mDead = true; } - + void CreatureStats::setLevel(int level) { mLevel = level; @@ -189,24 +190,24 @@ namespace MWMechanics assert (index>=0 && index<4); mAiSettings[index] = value; } - + bool CreatureStats::isDead() const { return mDead; } - + void CreatureStats::resurrect() { if (mDead) { if (mDynamic[0].getCurrent()<1) mDynamic[0].setCurrent (1); - + if (mDynamic[0].getCurrent()>=1) mDead = false; } } - + bool CreatureStats::hasCommonDisease() const { return mSpells.hasCommonDisease(); @@ -216,24 +217,59 @@ namespace MWMechanics { return mSpells.hasBlightDisease(); } - + int CreatureStats::getFriendlyHits() const { return mFriendlyHits; } - + void CreatureStats::friendlyHit() { ++mFriendlyHits; } - + bool CreatureStats::hasTalkedToPlayer() const { return mTalkedTo; } - + void CreatureStats::talkedToPlayer() { mTalkedTo = true; } + + bool CreatureStats::isAlarmed() const + { + return mAlarmed; + } + + void CreatureStats::setAlarmed (bool alarmed) + { + mAlarmed = alarmed; + } + + bool CreatureStats::getAttacked() const + { + return mAttacked; + } + + void CreatureStats::setAttacked (bool attacked) + { + mAttacked = attacked; + } + + bool CreatureStats::isHostile() const + { + return mHostile; + } + + void CreatureStats::setHostile (bool hostile) + { + mHostile = hostile; + } + + bool CreatureStats::getCreatureTargetted() const + { + return false; + } } diff --git a/apps/openmw/mwmechanics/creaturestats.hpp b/apps/openmw/mwmechanics/creaturestats.hpp index 937cb61cc7..3375c1af83 100644 --- a/apps/openmw/mwmechanics/creaturestats.hpp +++ b/apps/openmw/mwmechanics/creaturestats.hpp @@ -30,6 +30,9 @@ namespace MWMechanics bool mDead; int mFriendlyHits; bool mTalkedTo; + bool mAlarmed; + bool mAttacked; + bool mHostile; public: CreatureStats(); @@ -83,11 +86,11 @@ namespace MWMechanics void setAiSetting (int index, int value); ///< 0: hello, 1 fight, 2 flee, 3 alarm - + const AiSequence& getAiSequence() const; - + AiSequence& getAiSequence(); - + float getFatigueTerm() const; ///< Return effective fatigue @@ -96,23 +99,37 @@ namespace MWMechanics float getLevelHealthBonus() const; bool isDead() const; - + void resurrect(); - + bool hasCommonDisease() const; bool hasBlightDisease() const; - + int getFriendlyHits() const; ///< Number of friendly hits received. - + void friendlyHit(); ///< Increase number of friendly hits by one. - + bool hasTalkedToPlayer() const; ///< Has this creature talked with the player before? - + void talkedToPlayer(); + + bool isAlarmed() const; + + void setAlarmed (bool alarmed); + + bool getAttacked() const; + + void setAttacked (bool attacked); + + bool isHostile() const; + + void setHostile (bool hostile); + + bool getCreatureTargetted() const; }; } diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index 26415b6311..20a0360e77 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -22,7 +22,7 @@ MWMechanics::NpcStats::NpcStats() : mMovementFlags (0), mDrawState (DrawState_Nothing), mBounty (0) -, mLevelProgress(0), mDisposition(0), mVampire (0), mReputation(0) +, mLevelProgress(0), mDisposition(0), mVampire (0), mReputation(0), mWerewolf (false), mWerewolfKills (0) { mSkillIncreases.resize (ESM::Attribute::Length); for (int i=0; i<ESM::Attribute::Length; ++i) @@ -99,7 +99,7 @@ bool MWMechanics::NpcStats::isSameFaction (const NpcStats& npcStats) const ++iter) if (npcStats.mFactionRank.find (iter->first)!=npcStats.mFactionRank.end()) return true; - + return false; } @@ -280,10 +280,10 @@ void MWMechanics::NpcStats::setBounty (int bounty) int MWMechanics::NpcStats::getFactionReputation (const std::string& faction) const { std::map<std::string, int>::const_iterator iter = mFactionReputation.find (faction); - + if (iter==mFactionReputation.end()) return 0; - + return iter->second; } @@ -321,19 +321,33 @@ bool MWMechanics::NpcStats::hasSkillsForRank (const std::string& factionId, int *MWBase::Environment::get().getWorld()->getStore().get<ESM::Faction>().find (factionId); std::vector<int> skills; - + for (int i=0; i<6; ++i) skills.push_back (static_cast<int> (getSkill (faction.mData.mSkillID[i]).getModified())); - + std::sort (skills.begin(), skills.end()); - + std::vector<int>::const_reverse_iterator iter = skills.rbegin(); - + const ESM::RankData& rankData = faction.mData.mRankData[rank]; - + if (*iter<rankData.mSkill1) return false; - + return *++iter>=rankData.mSkill2; } +bool MWMechanics::NpcStats::isWerewolf() const +{ + return mWerewolf; +} + +void MWMechanics::NpcStats::setWerewolf (bool set) +{ + mWerewolf = set; +} + +int MWMechanics::NpcStats::getWerewolfKills() const +{ + return mWerewolfKills; +} \ No newline at end of file diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index 46af216d9c..af32bd294a 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -51,6 +51,8 @@ namespace MWMechanics std::map<std::string, int> mFactionReputation; bool mVampire; int mReputation; + bool mWerewolf; + int mWerewolfKills; int mLevelProgress; // 0-10 @@ -83,7 +85,7 @@ namespace MWMechanics Stat<float>& getSkill (int index); std::map<std::string, int>& getFactionRanks(); - + std::set<std::string>& getExpelled(); bool isSameFaction (const NpcStats& npcStats) const; @@ -107,24 +109,30 @@ namespace MWMechanics int getLevelupAttributeMultiplier(int attribute) const; void levelUp(); - + void flagAsUsed (const std::string& id); - + bool hasBeenUsed (const std::string& id) const; - + int getBounty() const; - + void setBounty (int bounty); - + int getFactionReputation (const std::string& faction) const; - + void setFactionReputation (const std::string& faction, int value); - + bool isVampire() const; - + void setVampire (bool set); - + bool hasSkillsForRank (const std::string& factionId, int rank) const; + + bool isWerewolf() const; + + void setWerewolf (bool set); + + int getWerewolfKills() const; }; } diff --git a/apps/openmw/mwworld/class.cpp b/apps/openmw/mwworld/class.cpp index 8c639a874c..c760191496 100644 --- a/apps/openmw/mwworld/class.cpp +++ b/apps/openmw/mwworld/class.cpp @@ -162,6 +162,11 @@ namespace MWWorld return false; } + bool Class::hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const + { + return false; + } + const Class& Class::get (const std::string& key) { std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key); diff --git a/apps/openmw/mwworld/class.hpp b/apps/openmw/mwworld/class.hpp index 4662cbab63..07dcb8fe03 100644 --- a/apps/openmw/mwworld/class.hpp +++ b/apps/openmw/mwworld/class.hpp @@ -191,6 +191,11 @@ namespace MWWorld /// /// (default implementation: return false) + virtual bool hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const; + ///< Has \æ ptr detected \a ptr2? + /// + /// (default implementation: return false) + static const Class& get (const std::string& key); ///< If there is no class for this \a key, an exception is thrown. From 4b939c7521ece2f9db5258b44495faa1cfd15f3c Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Thu, 15 Nov 2012 22:15:20 +0100 Subject: [PATCH 234/255] Feature #391 Dummy AI package classes --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwmechanics/aiescort.cpp | 21 ++++------------ apps/openmw/mwmechanics/aiescort.hpp | 21 ++++++---------- apps/openmw/mwmechanics/aifallow.cpp | 27 --------------------- apps/openmw/mwmechanics/aifallow.hpp | 36 ---------------------------- apps/openmw/mwmechanics/aitravel.cpp | 21 +++++++--------- apps/openmw/mwmechanics/aitravel.hpp | 18 +++++--------- apps/openmw/mwmechanics/aiwander.cpp | 16 ++++--------- apps/openmw/mwmechanics/aiwander.hpp | 14 +++-------- 9 files changed, 34 insertions(+), 142 deletions(-) delete mode 100644 apps/openmw/mwmechanics/aifallow.cpp delete mode 100644 apps/openmw/mwmechanics/aifallow.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index cdfbcc27db..e513c9dd5d 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -63,7 +63,7 @@ add_openmw_dir (mwclass add_openmw_dir (mwmechanics mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells - activespells npcstats aipackage aisequence alchemy aiwander aitravel aifallow aiescort + activespells npcstats aipackage aisequence alchemy aiwander aitravel aifollow aiescort aiactivate ) add_openmw_dir (mwbase diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index eac5d3bf5f..fd7b9bf326 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -1,25 +1,18 @@ #include "aiescort.hpp" +#include <iostream> - -MWMechanics::AiEscort::AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset) +MWMechanics::AiEscort::AiEscort(const std::string &ActorID,int Duration, float X, float Y, float Z): +mActorID(ActorID), mDuration(Duration), mX(X), mY(Y), mZ(Z) { - mActorID = ActorID; - mDuration = Duration; - mX = X; - mY = Y; - mZ = Z; - mReset = Reset; - } MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const { - AiEscort * temp = new AiEscort(*this); - return temp; + return new AiEscort(*this); } bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor) { - std::cout << "AiEscort complted. \n"; + std::cout << "AiEscort completed. \n"; return true; } @@ -40,10 +33,6 @@ float MWMechanics::AiEscort::getZ() { return mZ; } -bool MWMechanics::AiEscort::getReset() -{ - return mReset; -} std::string MWMechanics::AiEscort::getActorID() { diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp index cc6a1ec297..e39327e041 100644 --- a/apps/openmw/mwmechanics/aiescort.hpp +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -1,21 +1,15 @@ -#ifndef AIESCORT_H -#define AIESCORT_H +#ifndef GAME_MWMECHANICS_AIESCORT_H +#define GAME_MWMECHANICS_AIESCORT_H -#include "aipackage.hpp" -#include <iostream> -#include <vector> - -namespace MWWorld -{ -class Ptr; -} +#include "aipackage.hpp" +#include <string> namespace MWMechanics { class AiEscort : public AiPackage { public: - AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset = false); + AiEscort(const std::string &ActorID,int Duration, float X, float Y, float Z); virtual AiEscort *clone() const; virtual bool execute (const MWWorld::Ptr& actor); @@ -25,7 +19,6 @@ class AiEscort : public AiPackage float getX(); float getY(); float getZ(); - bool getReset(); std::string getActorID(); int getDuration(); @@ -35,7 +28,7 @@ class AiEscort : public AiPackage float mY; float mZ; int mDuration; - bool mReset; + }; } -#endif // AIESCORT_H +#endif diff --git a/apps/openmw/mwmechanics/aifallow.cpp b/apps/openmw/mwmechanics/aifallow.cpp deleted file mode 100644 index 2ba5277618..0000000000 --- a/apps/openmw/mwmechanics/aifallow.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "aifallow.hpp" - -MWMechanics::AiFallow::AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset) -{ - mActorID = ActorID; - mDuration = duration; - mX = X; - mY = Y; - mZ = Z; - mReset = Reset; -} -MWMechanics::AiFallow *MWMechanics::AiFallow::clone() const -{ - AiFallow * temp = new AiFallow(*this); - return temp; -} - - bool MWMechanics::AiFallow::execute (const MWWorld::Ptr& actor) -{ - std::cout << "AiFallow complited. \n"; - return true; -} - - int MWMechanics::AiFallow::getTypeId() const -{ - return 3; -} diff --git a/apps/openmw/mwmechanics/aifallow.hpp b/apps/openmw/mwmechanics/aifallow.hpp deleted file mode 100644 index b602bf300f..0000000000 --- a/apps/openmw/mwmechanics/aifallow.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef AIFALLOW_H -#define AIFALLOW_H - -#include "aipackage.hpp" -#include <string> -#include <iostream> - -namespace MWWorld -{ -class Ptr; -} - -namespace MWMechanics -{ - -class AiFallow : AiPackage -{ - public: - AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset = false); - virtual AiFallow *clone() const; - - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - - virtual int getTypeId() const; - ///< 0: Wanter, 1 Travel, 2 Escort, 3 Follo - private: - float mDuration; - float mX; - float mY; - float mZ; - bool mReset; - std::string mActorID; -}; -} -#endif // AIFALLOW_H diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index a71c857834..d07d302284 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -1,22 +1,22 @@ #include "aitravel.hpp" +#include <iostream> -MWMechanics::AiTravel::AiTravel(float x, float y, float z, bool reset) +MWMechanics::AiTravel::AiTravel(float x, float y, float z): +mX(x),mY(y),mZ(z) { - mX = x; - mY = y; - mZ = z; - mReset = reset; } + MWMechanics::AiTravel * MWMechanics::AiTravel::clone() const { - AiTravel * temp = new AiTravel(*this); - return temp; + return new AiTravel(*this); } + bool MWMechanics::AiTravel::execute (const MWWorld::Ptr& actor) { - std::cout << "AiTravel complited. \n"; + std::cout << "AiTravel completed.\n"; return true; } + int MWMechanics::AiTravel::getTypeId() const { return 1; @@ -27,7 +27,6 @@ float MWMechanics::AiTravel::getX() return mX; } - float MWMechanics::AiTravel::getY() { return mY; @@ -38,7 +37,3 @@ float MWMechanics::AiTravel::getZ() return mZ; } -bool MWMechanics::AiTravel::getReset() -{ - return mReset; -} diff --git a/apps/openmw/mwmechanics/aitravel.hpp b/apps/openmw/mwmechanics/aitravel.hpp index 0503935fd4..86032cf547 100644 --- a/apps/openmw/mwmechanics/aitravel.hpp +++ b/apps/openmw/mwmechanics/aitravel.hpp @@ -1,20 +1,14 @@ -#ifndef AITRAVEL_HPP_INCLUDED -#define AITRAVEL_HPP_INCLUDED +#ifndef GAME_MWMECHANICS_AITRAVEL_H +#define GAME_MWMECHANICS_AITRAVEL_H #include "aipackage.hpp" -#include <iostream> - -namespace MWWorld -{ -class Ptr; -} namespace MWMechanics { class AiTravel : public AiPackage { public: - AiTravel(float x, float y, float z, bool reset = false); + AiTravel(float x, float y, float z); virtual AiTravel *clone() const; virtual bool execute (const MWWorld::Ptr& actor); @@ -24,14 +18,14 @@ class AiTravel : public AiPackage float getX(); float getY(); float getZ(); - bool getReset(); + private: float mX; float mY; float mZ; - bool mReset; + }; } -#endif // AITRAVEL_HPP_INCLUDED +#endif diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index b77b2c04bc..ac39fe94d5 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -1,12 +1,9 @@ #include "aiwander.hpp" +#include <iostream> -MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset) +MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle): + mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(Idle) { - mDistance = distance; - mDuration = duration; - mTimeOfDay = timeOfDay; - mIdle = Idle; - mReset = reset; } int MWMechanics::AiWander::getDistance() const @@ -24,11 +21,6 @@ int MWMechanics::AiWander::getTimeOfDay() const return mTimeOfDay; } -bool MWMechanics::AiWander::getReset() const -{ - return mReset; -} - MWMechanics::AiPackage * MWMechanics::AiWander::clone() const { return new AiWander(*this); @@ -36,7 +28,7 @@ MWMechanics::AiPackage * MWMechanics::AiWander::clone() const bool MWMechanics::AiWander::execute (const MWWorld::Ptr& actor) { - std::cout << "AiWadner complited. \n"; + std::cout << "AiWadner completed.\n"; return true; } diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index 6ecd7f1008..64168042ca 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -1,15 +1,9 @@ -#ifndef AIWANDER_H -#define AIWANDER_H +#ifndef GAME_MWMECHANICS_AIWANDER_H +#define GAME_MWMECHANICS_AIWANDER_H #include "aipackage.hpp" -#include <iostream> #include <vector> -namespace MWWorld -{ -class Ptr; -} - namespace MWMechanics { @@ -17,7 +11,7 @@ class AiWander : public AiPackage { public: - AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset=false); + AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle); virtual AiPackage *clone() const; virtual bool execute (const MWWorld::Ptr& actor); ///< \return Package completed? @@ -27,7 +21,6 @@ public: int getDistance() const; int getDuration()const; int getTimeOfDay()const; - bool getReset()const; int getIdle(int index) const; private: @@ -35,7 +28,6 @@ private: int mDuration; int mTimeOfDay; std::vector<int> mIdle; - bool mReset; }; } From 515419ae0beb762b68822cfb572ad840e7899e3a Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Thu, 15 Nov 2012 22:22:44 +0100 Subject: [PATCH 235/255] Feature #391 Dummy AI package classes --- apps/openmw/mwmechanics/aiactivate.cpp | 21 +++++++++++++++++++++ apps/openmw/mwmechanics/aiactivate.hpp | 23 +++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 apps/openmw/mwmechanics/aiactivate.cpp create mode 100644 apps/openmw/mwmechanics/aiactivate.hpp diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp new file mode 100644 index 0000000000..72dfae11bf --- /dev/null +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -0,0 +1,21 @@ +#include "aiactivate.hpp" +#include <iostream> + +MWMechanics::AiActivate::AiActivate(const MWWorld::Ptr& object) +{ + mObject = &object; +} +MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const +{ + return new AiActivate(*this); +} +bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiActivate completed.\n"; + return true; +} + +int MWMechanics::AiActivate::getTypeId() const +{ + return 4; +} diff --git a/apps/openmw/mwmechanics/aiactivate.hpp b/apps/openmw/mwmechanics/aiactivate.hpp new file mode 100644 index 0000000000..c314cb2f56 --- /dev/null +++ b/apps/openmw/mwmechanics/aiactivate.hpp @@ -0,0 +1,23 @@ +#ifndef GAME_MWMECHANICS_AIACTIVATE_H +#define GAME_MWMECHANICS_AIACTIVATE_H + +#include "aipackage.hpp" + + +namespace MWMechanics +{ + +class AiActivate : AiPackage +{ + public: + AiActivate(const MWWorld::Ptr& object); + virtual AiActivate *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; + + private: + const MWWorld::Ptr * mObject; +}; +} +#endif // GAME_MWMECHANICS_AIACTIVATE_H From 96dd399457f6e41c96ae5b1ff47fd4f29af1dd6e Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Thu, 15 Nov 2012 22:30:15 +0100 Subject: [PATCH 236/255] Feature #391 Dummy AI package classes --- openmw/apps/openmw/CMakeLists.txt | 132 -------------------- openmw/apps/openmw/mwmechanics/aiescort.cpp | 56 --------- openmw/apps/openmw/mwmechanics/aiescort.hpp | 41 ------ openmw/apps/openmw/mwmechanics/aifallow.cpp | 27 ---- openmw/apps/openmw/mwmechanics/aifallow.hpp | 36 ------ openmw/apps/openmw/mwmechanics/aitravel.cpp | 44 ------- openmw/apps/openmw/mwmechanics/aitravel.hpp | 37 ------ openmw/apps/openmw/mwmechanics/aiwander.cpp | 55 -------- openmw/apps/openmw/mwmechanics/aiwander.hpp | 42 ------- 9 files changed, 470 deletions(-) delete mode 100644 openmw/apps/openmw/CMakeLists.txt delete mode 100644 openmw/apps/openmw/mwmechanics/aiescort.cpp delete mode 100644 openmw/apps/openmw/mwmechanics/aiescort.hpp delete mode 100644 openmw/apps/openmw/mwmechanics/aifallow.cpp delete mode 100644 openmw/apps/openmw/mwmechanics/aifallow.hpp delete mode 100644 openmw/apps/openmw/mwmechanics/aitravel.cpp delete mode 100644 openmw/apps/openmw/mwmechanics/aitravel.hpp delete mode 100644 openmw/apps/openmw/mwmechanics/aiwander.cpp delete mode 100644 openmw/apps/openmw/mwmechanics/aiwander.hpp diff --git a/openmw/apps/openmw/CMakeLists.txt b/openmw/apps/openmw/CMakeLists.txt deleted file mode 100644 index cdfbcc27db..0000000000 --- a/openmw/apps/openmw/CMakeLists.txt +++ /dev/null @@ -1,132 +0,0 @@ - -# config file -configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/config.hpp.cmake" "${CMAKE_CURRENT_SOURCE_DIR}/config.hpp") - -# local files -set(GAME - main.cpp - engine.cpp -) -set(GAME_HEADER - engine.hpp - config.hpp -) -source_group(game FILES ${GAME} ${GAME_HEADER}) - -add_openmw_dir (mwrender - renderingmanager debugging sky player animation npcanimation creatureanimation actors objects - renderinginterface localmap occlusionquery terrain terrainmaterial water shadows - compositors characterpreview externalrendering globalmap - ) - -add_openmw_dir (mwinput - inputmanagerimp - ) - -add_openmw_dir (mwgui - text_input widgets race class birth review windowmanagerimp console dialogue - dialogue_history window_base stats_window messagebox journalwindow charactercreation - map_window window_pinnable_base cursorreplace tooltips scrollwindow bookwindow list - formatting inventorywindow container hud countdialog tradewindow settingswindow - confirmationdialog alchemywindow referenceinterface spellwindow mainmenu quickkeysmenu - itemselection spellbuyingwindow loadingscreen levelupdialog waitdialog spellcreationdialog - enchantingdialog trainingwindow travelwindow - ) - -add_openmw_dir (mwdialogue - dialoguemanagerimp journalimp journalentry quest topic - ) - -add_openmw_dir (mwscript - locals scriptmanagerimp compilercontext interpretercontext cellextensions miscextensions - guiextensions soundextensions skyextensions statsextensions containerextensions - aiextensions controlextensions extensions globalscripts ref dialogueextensions - animationextensions transformationextensions consoleextensions userextensions - ) - -add_openmw_dir (mwsound - soundmanagerimp openal_output audiere_decoder mpgsnd_decoder ffmpeg_decoder - ) - -add_openmw_dir (mwworld - refdata worldimp physicssystem scene globals class action nullaction actionteleport - containerstore actiontalk actiontake manualref player cellfunctors - cells localscripts customdata weather inventorystore ptr actionopen actionread - actionequip timestamp actionalchemy cellstore actionapply actioneat - esmstore store recordcmp - ) - -add_openmw_dir (mwclass - classes activator creature npc weapon armor potion apparatus book clothing container door - ingredient creaturelevlist itemlevlist light lockpick misc probe repair static - ) - -add_openmw_dir (mwmechanics - mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells - activespells npcstats aipackage aisequence alchemy aiwander aitravel aifallow aiescort - ) - -add_openmw_dir (mwbase - environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager - inputmanager windowmanager - ) - -# Main executable -IF(OGRE_STATIC) -IF(WIN32) -ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_-DENABLE_PLUGIN_Direct3D9 -DENABLE_PLUGIN_GL) -set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_Direct3D9_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) -ELSE(WIN32) -ADD_DEFINITIONS(-DENABLE_PLUGIN_CgProgramManager -DENABLE_PLUGIN_OctreeSceneManager -DENABLE_PLUGIN_ParticleFX -DENABLE_PLUGIN_GL) -set(OGRE_STATIC_PLUGINS ${OGRE_Plugin_CgProgramManager_LIBRARIES} ${Cg_LIBRARIES} ${OGRE_Plugin_OctreeSceneManager_LIBRARIES} ${OGRE_Plugin_ParticleFX_LIBRARIES} ${OGRE_RenderSystem_GL_LIBRARIES}) -ENDIF(WIN32) -ENDIF(OGRE_STATIC) -add_executable(openmw - ${OPENMW_LIBS} ${OPENMW_LIBS_HEADER} - ${OPENMW_FILES} - ${GAME} ${GAME_HEADER} - ${APPLE_BUNDLE_RESOURCES} -) - -# Sound stuff - here so CMake doesn't stupidly recompile EVERYTHING -# when we change the backend. -include_directories(${SOUND_INPUT_INCLUDES} ${BULLET_INCLUDE_DIRS}) -add_definitions(${SOUND_DEFINE}) - -target_link_libraries(openmw - ${OGRE_LIBRARIES} - ${OGRE_Terrain_LIBRARY} - ${OGRE_STATIC_PLUGINS} - ${OIS_LIBRARIES} - ${Boost_LIBRARIES} - ${OPENAL_LIBRARY} - ${SOUND_INPUT_LIBRARY} - ${BULLET_LIBRARIES} - ${MYGUI_LIBRARIES} - ${MYGUI_PLATFORM_LIBRARIES} - "shiny" - "shiny.OgrePlatform" - "oics" - components -) - -# Fix for not visible pthreads functions for linker with glibc 2.15 -if (UNIX AND NOT APPLE) -target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) -endif() - -if(APPLE) - find_library(CARBON_FRAMEWORK Carbon) - find_library(COCOA_FRAMEWORK Cocoa) - find_library(IOKIT_FRAMEWORK IOKit) - target_link_libraries(openmw ${CARBON_FRAMEWORK} ${COCOA_FRAMEWORK} ${IOKIT_FRAMEWORK}) -endif(APPLE) - -if(DPKG_PROGRAM) - INSTALL(TARGETS openmw RUNTIME DESTINATION games COMPONENT openmw) -endif(DPKG_PROGRAM) - -if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(openmw gcov) -endif() diff --git a/openmw/apps/openmw/mwmechanics/aiescort.cpp b/openmw/apps/openmw/mwmechanics/aiescort.cpp deleted file mode 100644 index eac5d3bf5f..0000000000 --- a/openmw/apps/openmw/mwmechanics/aiescort.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "aiescort.hpp" - - -MWMechanics::AiEscort::AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset) -{ - mActorID = ActorID; - mDuration = Duration; - mX = X; - mY = Y; - mZ = Z; - mReset = Reset; - -} -MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const -{ - AiEscort * temp = new AiEscort(*this); - return temp; -} - -bool MWMechanics::AiEscort::execute (const MWWorld::Ptr& actor) -{ - std::cout << "AiEscort complted. \n"; - return true; -} - -int MWMechanics::AiEscort::getTypeId() const -{ - return 2; -} - -float MWMechanics::AiEscort::getX() -{ - return mX; -} -float MWMechanics::AiEscort::getY() -{ - return mY; -} -float MWMechanics::AiEscort::getZ() -{ - return mZ; -} -bool MWMechanics::AiEscort::getReset() -{ - return mReset; -} - -std::string MWMechanics::AiEscort::getActorID() -{ - return mActorID; -} - -int MWMechanics::AiEscort::getDuration() -{ - return mDuration; -} diff --git a/openmw/apps/openmw/mwmechanics/aiescort.hpp b/openmw/apps/openmw/mwmechanics/aiescort.hpp deleted file mode 100644 index cc6a1ec297..0000000000 --- a/openmw/apps/openmw/mwmechanics/aiescort.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef AIESCORT_H -#define AIESCORT_H - -#include "aipackage.hpp" -#include <iostream> -#include <vector> - -namespace MWWorld -{ -class Ptr; -} - -namespace MWMechanics -{ -class AiEscort : public AiPackage -{ - public: - AiEscort(std::string ActorID,int Duration, float X, float Y, float Z, bool Reset = false); - virtual AiEscort *clone() const; - - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - - virtual int getTypeId() const; - float getX(); - float getY(); - float getZ(); - bool getReset(); - std::string getActorID(); - int getDuration(); - - private: - std::string mActorID; - float mX; - float mY; - float mZ; - int mDuration; - bool mReset; -}; -} -#endif // AIESCORT_H diff --git a/openmw/apps/openmw/mwmechanics/aifallow.cpp b/openmw/apps/openmw/mwmechanics/aifallow.cpp deleted file mode 100644 index 2ba5277618..0000000000 --- a/openmw/apps/openmw/mwmechanics/aifallow.cpp +++ /dev/null @@ -1,27 +0,0 @@ -#include "aifallow.hpp" - -MWMechanics::AiFallow::AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset) -{ - mActorID = ActorID; - mDuration = duration; - mX = X; - mY = Y; - mZ = Z; - mReset = Reset; -} -MWMechanics::AiFallow *MWMechanics::AiFallow::clone() const -{ - AiFallow * temp = new AiFallow(*this); - return temp; -} - - bool MWMechanics::AiFallow::execute (const MWWorld::Ptr& actor) -{ - std::cout << "AiFallow complited. \n"; - return true; -} - - int MWMechanics::AiFallow::getTypeId() const -{ - return 3; -} diff --git a/openmw/apps/openmw/mwmechanics/aifallow.hpp b/openmw/apps/openmw/mwmechanics/aifallow.hpp deleted file mode 100644 index b602bf300f..0000000000 --- a/openmw/apps/openmw/mwmechanics/aifallow.hpp +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef AIFALLOW_H -#define AIFALLOW_H - -#include "aipackage.hpp" -#include <string> -#include <iostream> - -namespace MWWorld -{ -class Ptr; -} - -namespace MWMechanics -{ - -class AiFallow : AiPackage -{ - public: - AiFallow(std::string ActorID,float duration, float X, float Y, float Z, bool Reset = false); - virtual AiFallow *clone() const; - - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - - virtual int getTypeId() const; - ///< 0: Wanter, 1 Travel, 2 Escort, 3 Follo - private: - float mDuration; - float mX; - float mY; - float mZ; - bool mReset; - std::string mActorID; -}; -} -#endif // AIFALLOW_H diff --git a/openmw/apps/openmw/mwmechanics/aitravel.cpp b/openmw/apps/openmw/mwmechanics/aitravel.cpp deleted file mode 100644 index a71c857834..0000000000 --- a/openmw/apps/openmw/mwmechanics/aitravel.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "aitravel.hpp" - -MWMechanics::AiTravel::AiTravel(float x, float y, float z, bool reset) -{ - mX = x; - mY = y; - mZ = z; - mReset = reset; -} -MWMechanics::AiTravel * MWMechanics::AiTravel::clone() const -{ - AiTravel * temp = new AiTravel(*this); - return temp; -} -bool MWMechanics::AiTravel::execute (const MWWorld::Ptr& actor) -{ - std::cout << "AiTravel complited. \n"; - return true; -} -int MWMechanics::AiTravel::getTypeId() const -{ - return 1; -} - -float MWMechanics::AiTravel::getX() -{ - return mX; -} - - -float MWMechanics::AiTravel::getY() -{ - return mY; -} - -float MWMechanics::AiTravel::getZ() -{ - return mZ; -} - -bool MWMechanics::AiTravel::getReset() -{ - return mReset; -} diff --git a/openmw/apps/openmw/mwmechanics/aitravel.hpp b/openmw/apps/openmw/mwmechanics/aitravel.hpp deleted file mode 100644 index 0503935fd4..0000000000 --- a/openmw/apps/openmw/mwmechanics/aitravel.hpp +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef AITRAVEL_HPP_INCLUDED -#define AITRAVEL_HPP_INCLUDED - -#include "aipackage.hpp" -#include <iostream> - -namespace MWWorld -{ -class Ptr; -} - -namespace MWMechanics -{ -class AiTravel : public AiPackage -{ - public: - AiTravel(float x, float y, float z, bool reset = false); - virtual AiTravel *clone() const; - - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - - virtual int getTypeId() const; - float getX(); - float getY(); - float getZ(); - bool getReset(); - - private: - float mX; - float mY; - float mZ; - bool mReset; -}; -} - -#endif // AITRAVEL_HPP_INCLUDED diff --git a/openmw/apps/openmw/mwmechanics/aiwander.cpp b/openmw/apps/openmw/mwmechanics/aiwander.cpp deleted file mode 100644 index b77b2c04bc..0000000000 --- a/openmw/apps/openmw/mwmechanics/aiwander.cpp +++ /dev/null @@ -1,55 +0,0 @@ -#include "aiwander.hpp" - -MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset) -{ - mDistance = distance; - mDuration = duration; - mTimeOfDay = timeOfDay; - mIdle = Idle; - mReset = reset; -} - -int MWMechanics::AiWander::getDistance() const -{ - return mDistance; -} - -int MWMechanics::AiWander::getDuration() const -{ - return mDuration; -} - -int MWMechanics::AiWander::getTimeOfDay() const -{ - return mTimeOfDay; -} - -bool MWMechanics::AiWander::getReset() const -{ - return mReset; -} - -MWMechanics::AiPackage * MWMechanics::AiWander::clone() const -{ - return new AiWander(*this); -} - -bool MWMechanics::AiWander::execute (const MWWorld::Ptr& actor) -{ - std::cout << "AiWadner complited. \n"; - return true; -} - -int MWMechanics::AiWander::getTypeId() const -{ - return 0; -} - -int MWMechanics::AiWander::getIdle(int index) const -{ - if(index < 0 || (uint)index > mIdle.size()) - return -1; - int temp; - temp = mIdle.at(index); - return temp; -} diff --git a/openmw/apps/openmw/mwmechanics/aiwander.hpp b/openmw/apps/openmw/mwmechanics/aiwander.hpp deleted file mode 100644 index 6ecd7f1008..0000000000 --- a/openmw/apps/openmw/mwmechanics/aiwander.hpp +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef AIWANDER_H -#define AIWANDER_H - -#include "aipackage.hpp" -#include <iostream> -#include <vector> - -namespace MWWorld -{ -class Ptr; -} - -namespace MWMechanics -{ - -class AiWander : public AiPackage -{ -public: - - AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle,bool reset=false); - virtual AiPackage *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - virtual int getTypeId() const; - ///< 0: Wander - - int getDistance() const; - int getDuration()const; - int getTimeOfDay()const; - bool getReset()const; - int getIdle(int index) const; - -private: - int mDistance; - int mDuration; - int mTimeOfDay; - std::vector<int> mIdle; - bool mReset; -}; -} - -#endif // AIWANDER_H From 99ddc63e2c4d165a8b9f9f8d3b47d4c585bf3b94 Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Thu, 15 Nov 2012 22:32:15 +0100 Subject: [PATCH 237/255] Feature #391 Dummy AI package classes --- apps/openmw/mwmechanics/aifollow.cpp | 22 ++++++++++++++++++++++ apps/openmw/mwmechanics/aifollow.hpp | 27 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 apps/openmw/mwmechanics/aifollow.cpp create mode 100644 apps/openmw/mwmechanics/aifollow.hpp diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp new file mode 100644 index 0000000000..abb51102b1 --- /dev/null +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -0,0 +1,22 @@ +#include "aifollow.hpp" +#include <iostream> + +MWMechanics::AiFollow::AiFollow(const std::string &ActorID,float duration, float X, float Y, float Z): +mActorID(ActorID), mDuration(duration), mX(X), mY(Y), mZ(Z) +{ +} +MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const +{ + return new AiFollow(*this); +} + + bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor) +{ + std::cout << "AiFollow completed.\n"; + return true; +} + + int MWMechanics::AiFollow::getTypeId() const +{ + return 3; +} diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp new file mode 100644 index 0000000000..f2e716ebf2 --- /dev/null +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -0,0 +1,27 @@ +#ifndef GAME_MWMECHANICS_AIFALLOW_H +#define GAME_MWMECHANICS_AIFALLOW_H + +#include "aipackage.hpp" +#include <string> + +namespace MWMechanics +{ + +class AiFollow : AiPackage +{ + public: + AiFollow(const std::string &ActorID,float duration, float X, float Y, float Z); + virtual AiFollow *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; + + private: + float mDuration; + float mX; + float mY; + float mZ; + std::string mActorID; +}; +} +#endif From bed0280ba1b789c0b8cb0350bffe5fdbbf154607 Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Thu, 15 Nov 2012 22:33:50 +0100 Subject: [PATCH 238/255] Feature #391 Dummy AI package classes --- apps/openmw/mwmechanics/aiwander.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index ac39fe94d5..71159b94bf 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -41,7 +41,5 @@ int MWMechanics::AiWander::getIdle(int index) const { if(index < 0 || (uint)index > mIdle.size()) return -1; - int temp; - temp = mIdle.at(index); - return temp; + return mIdle.at(index); } From fd5671e6db92a9506b880326e7b6e9ff8c0b70ba Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 16 Nov 2012 12:45:07 +0100 Subject: [PATCH 239/255] fixed argument lists for setpcfacrep and modpcfacrep --- apps/openmw/mwscript/statsextensions.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 124eaf4c33..9bd517ba69 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -913,8 +913,8 @@ namespace MWScript extensions.registerFunction ("getdeadcount", 'l', "c", opcodeGetDeadCount); extensions.registerFunction ("getpcfacrep", 'l', "/c", opcodeGetPCFacRep, opcodeGetPCFacRepExplicit); - extensions.registerInstruction ("setpcfacrep", "/lc", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit); - extensions.registerInstruction ("modpcfacrep", "/lc", opcodeModPCFacRep, opcodeModPCFacRepExplicit); + extensions.registerInstruction ("setpcfacrep", "l/c", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit); + extensions.registerInstruction ("modpcfacrep", "l/c", opcodeModPCFacRep, opcodeModPCFacRepExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) From 89c79365342181cc4ea38fb745a4262acd619528 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 16 Nov 2012 12:47:09 +0100 Subject: [PATCH 240/255] fixed dialogue script error reporting --- apps/openmw/mwdialogue/dialoguemanagerimp.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 6a0f9d71f5..31cef7f70e 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -129,7 +129,7 @@ namespace MWDialogue mIsInChoice = false; mActor = actor; - + MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get (actor).getCreatureStats (actor); mTalkedTo = creatureStats.hasTalkedToPlayer(); creatureStats.talkedToPlayer(); @@ -175,7 +175,7 @@ namespace MWDialogue bool DialogueManager::compile (const std::string& cmd,std::vector<Interpreter::Type_Code>& code) { bool success = true; - + try { mErrorHandler.reset(); @@ -197,12 +197,12 @@ namespace MWDialogue Compiler::ScriptParser parser(mErrorHandler,mCompilerContext, locals, false); scanner.scan (parser); - + if (!mErrorHandler.isGood()) success = false; if (success) - parser.getCode (code); + parser.getCode (code); } catch (const Compiler::SourceException& /* error */) { @@ -211,7 +211,7 @@ namespace MWDialogue } catch (const std::exception& error) { - printError (std::string ("An exception has been thrown: ") + error.what()); + std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what() << std::endl; success = false; } @@ -240,7 +240,7 @@ namespace MWDialogue } catch (const std::exception& error) { - printError (std::string ("An exception has been thrown: ") + error.what()); + std::cerr << std::string ("Dialogue error: An exception has been thrown: ") + error.what(); } } } @@ -264,7 +264,7 @@ namespace MWDialogue if (filter.search (*iter)) { mActorKnownTopics.push_back (toLower (iter->mId)); - + //does the player know the topic? if (mKnownTopics.find (toLower (iter->mId)) != mKnownTopics.end()) { @@ -340,8 +340,8 @@ namespace MWDialogue if (mDialogueMap[keyword].mType == ESM::Dialogue::Topic) { Filter filter (mActor, mChoice, mTalkedTo); - - if (const ESM::DialInfo *info = filter.search (mDialogueMap[keyword])) + + if (const ESM::DialInfo *info = filter.search (mDialogueMap[keyword])) { std::string text = info->mResponse; std::string script = info->mResultScript; @@ -389,7 +389,7 @@ namespace MWDialogue if (mDialogueMap[mLastTopic].mType == ESM::Dialogue::Topic) { Filter filter (mActor, mChoice, mTalkedTo); - + if (const ESM::DialInfo *info = filter.search (mDialogueMap[mLastTopic])) { mChoiceMap.clear(); @@ -404,7 +404,7 @@ namespace MWDialogue } } } - + updateTopics(); } } From 9193f3b0aea4047551cce8e20bd947f7e52a8bc3 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 16 Nov 2012 13:32:40 +0100 Subject: [PATCH 241/255] implemented getCommon/BlightDisease script instructions --- apps/openmw/mwscript/docs/vmformat.txt | 10 ++++-- apps/openmw/mwscript/statsextensions.cpp | 40 ++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 4ec9cfb99b..5a939b5db0 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -204,9 +204,9 @@ op 0x2000197: Position Explicit op 0x2000198: PositionCell op 0x2000199: PositionCell Explicit op 0x200019a: PlaceItemCell -op 0x200019b: PlaceItem +op 0x200019b: PlaceItem op 0x200019c: PlaceAtPc -op 0x200019d: PlaceAtMe +op 0x200019d: PlaceAtMe op 0x200019e: PlaceAtMe Explicit op 0x200019f: GetPcSleep op 0x20001a0: ShowMap @@ -217,5 +217,9 @@ op 0x20001a4: SetDisposition op 0x20001a5: SetDisposition, Explicit op 0x20001a6: GetDisposition op 0x20001a7: GetDisposition, Explicit -opcodes 0x20001a8-0x3ffffff unused +op 0x20001a8: CommonDisease +op 0x20001a9: CommonDisease, explicit reference +op 0x20001aa: BlightDisease +op 0x20001ab: BlightDisease, explicit reference +opcodes 0x20001ac-0x3ffffff unused diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 9bd517ba69..f6a31dd7f7 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -754,6 +754,32 @@ namespace MWScript } }; + template<class R> + class OpGetCommonDisease : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push (MWWorld::Class::get (ptr).getCreatureStats (ptr).hasCommonDisease()); + } + }; + + template<class R> + class OpGetBlightDisease : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + + runtime.push (MWWorld::Class::get (ptr).getCreatureStats (ptr).hasBlightDisease()); + } + }; + const int numberOfAttributes = 8; @@ -819,6 +845,10 @@ namespace MWScript const int opcodeModPCFacRep = 0x20016; const int opcodeModPCFacRepExplicit = 0x20017; + const int opcodeGetCommonDisease = 0x20001a8; + const int opcodeGetCommonDiseaseExplicit = 0x20001a9; + const int opcodeGetBlightDisease = 0x20001aa; + const int opcodeGetBlightDiseaseExplicit = 0x20001ab; void registerExtensions (Compiler::Extensions& extensions) { @@ -915,6 +945,11 @@ namespace MWScript extensions.registerFunction ("getpcfacrep", 'l', "/c", opcodeGetPCFacRep, opcodeGetPCFacRepExplicit); extensions.registerInstruction ("setpcfacrep", "l/c", opcodeSetPCFacRep, opcodeSetPCFacRepExplicit); extensions.registerInstruction ("modpcfacrep", "l/c", opcodeModPCFacRep, opcodeModPCFacRepExplicit); + + extensions.registerFunction ("getcommondisease", 'l', "", opcodeGetCommonDisease, + opcodeGetCommonDiseaseExplicit); + extensions.registerFunction ("getblightdisease", 'l', "", opcodeGetBlightDisease, + opcodeGetBlightDiseaseExplicit); } void installOpcodes (Interpreter::Interpreter& interpreter) @@ -1005,6 +1040,11 @@ namespace MWScript interpreter.installSegment3 (opcodeSetPCFacRepExplicit, new OpSetPCFacRep<ExplicitRef>); interpreter.installSegment3 (opcodeModPCFacRep, new OpModPCFacRep<ImplicitRef>); interpreter.installSegment3 (opcodeModPCFacRepExplicit, new OpModPCFacRep<ExplicitRef>); + + interpreter.installSegment5 (opcodeGetCommonDisease, new OpGetCommonDisease<ImplicitRef>); + interpreter.installSegment5 (opcodeGetCommonDiseaseExplicit, new OpGetCommonDisease<ExplicitRef>); + interpreter.installSegment5 (opcodeGetBlightDisease, new OpGetBlightDisease<ImplicitRef>); + interpreter.installSegment5 (opcodeGetBlightDiseaseExplicit, new OpGetBlightDisease<ExplicitRef>); } } } From 51027c541e3ef6b448be96e91f9b24677e000a93 Mon Sep 17 00:00:00 2001 From: marcin <Gohan1989@gmail.com> Date: Fri, 16 Nov 2012 18:38:15 +0100 Subject: [PATCH 242/255] Feature #391 Dummy AI package classes --- apps/openmw/mwmechanics/aiactivate.cpp | 4 +-- apps/openmw/mwmechanics/aiactivate.hpp | 24 ++++++++-------- apps/openmw/mwmechanics/aiescort.cpp | 4 +-- apps/openmw/mwmechanics/aiescort.hpp | 40 +++++++++++++------------- apps/openmw/mwmechanics/aifollow.cpp | 4 +-- apps/openmw/mwmechanics/aifollow.hpp | 30 +++++++++---------- apps/openmw/mwmechanics/aitravel.hpp | 32 ++++++++++----------- apps/openmw/mwmechanics/aiwander.cpp | 6 ++-- apps/openmw/mwmechanics/aiwander.hpp | 40 +++++++++++++------------- 9 files changed, 91 insertions(+), 93 deletions(-) diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index 72dfae11bf..464b30c7c6 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -1,9 +1,9 @@ #include "aiactivate.hpp" #include <iostream> -MWMechanics::AiActivate::AiActivate(const MWWorld::Ptr& object) +MWMechanics::AiActivate::AiActivate(const std::string &objectID): +mObjectID(objectID) { - mObject = &object; } MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const { diff --git a/apps/openmw/mwmechanics/aiactivate.hpp b/apps/openmw/mwmechanics/aiactivate.hpp index c314cb2f56..5744cb25b3 100644 --- a/apps/openmw/mwmechanics/aiactivate.hpp +++ b/apps/openmw/mwmechanics/aiactivate.hpp @@ -2,22 +2,22 @@ #define GAME_MWMECHANICS_AIACTIVATE_H #include "aipackage.hpp" - +#include <string> namespace MWMechanics { -class AiActivate : AiPackage -{ - public: - AiActivate(const MWWorld::Ptr& object); - virtual AiActivate *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - virtual int getTypeId() const; + class AiActivate : AiPackage + { + public: + AiActivate(const std::string &objectID); + virtual AiActivate *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; - private: - const MWWorld::Ptr * mObject; -}; + private: + std::string mObjectID; + }; } #endif // GAME_MWMECHANICS_AIACTIVATE_H diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index fd7b9bf326..9f170ef6eb 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -1,8 +1,8 @@ #include "aiescort.hpp" #include <iostream> -MWMechanics::AiEscort::AiEscort(const std::string &ActorID,int Duration, float X, float Y, float Z): -mActorID(ActorID), mDuration(Duration), mX(X), mY(Y), mZ(Z) +MWMechanics::AiEscort::AiEscort(const std::string &actorID,int duration, float x, float y, float z): +mActorID(actorID), mDuration(duration), mX(x), mY(y), mZ(z) { } MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp index e39327e041..4bd3f4b220 100644 --- a/apps/openmw/mwmechanics/aiescort.hpp +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -6,29 +6,29 @@ namespace MWMechanics { -class AiEscort : public AiPackage -{ - public: - AiEscort(const std::string &ActorID,int Duration, float X, float Y, float Z); - virtual AiEscort *clone() const; + class AiEscort : public AiPackage + { + public: + AiEscort(const std::string &actorID,int duration, float x, float y, float z); + virtual AiEscort *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? - virtual int getTypeId() const; - float getX(); - float getY(); - float getZ(); - std::string getActorID(); - int getDuration(); + virtual int getTypeId() const; + float getX(); + float getY(); + float getZ(); + std::string getActorID(); + int getDuration(); - private: - std::string mActorID; - float mX; - float mY; - float mZ; - int mDuration; + private: + std::string mActorID; + float mX; + float mY; + float mZ; + int mDuration; -}; + }; } #endif diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index abb51102b1..6478544bc1 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -1,8 +1,8 @@ #include "aifollow.hpp" #include <iostream> -MWMechanics::AiFollow::AiFollow(const std::string &ActorID,float duration, float X, float Y, float Z): -mActorID(ActorID), mDuration(duration), mX(X), mY(Y), mZ(Z) +MWMechanics::AiFollow::AiFollow(const std::string &actorID,float duration, float x, float y, float z): +mActorID(actorID), mDuration(duration), mX(x), mY(y), mZ(z) { } MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp index f2e716ebf2..079c3c3810 100644 --- a/apps/openmw/mwmechanics/aifollow.hpp +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -7,21 +7,21 @@ namespace MWMechanics { -class AiFollow : AiPackage -{ - public: - AiFollow(const std::string &ActorID,float duration, float X, float Y, float Z); - virtual AiFollow *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - virtual int getTypeId() const; + class AiFollow : AiPackage + { + public: + AiFollow(const std::string &ActorID,float duration, float X, float Y, float Z); + virtual AiFollow *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; - private: - float mDuration; - float mX; - float mY; - float mZ; - std::string mActorID; -}; + private: + float mDuration; + float mX; + float mY; + float mZ; + std::string mActorID; + }; } #endif diff --git a/apps/openmw/mwmechanics/aitravel.hpp b/apps/openmw/mwmechanics/aitravel.hpp index 86032cf547..813ba81ebc 100644 --- a/apps/openmw/mwmechanics/aitravel.hpp +++ b/apps/openmw/mwmechanics/aitravel.hpp @@ -5,27 +5,27 @@ namespace MWMechanics { -class AiTravel : public AiPackage -{ - public: - AiTravel(float x, float y, float z); - virtual AiTravel *clone() const; + class AiTravel : public AiPackage + { + public: + AiTravel(float x, float y, float z); + virtual AiTravel *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? - virtual int getTypeId() const; - float getX(); - float getY(); - float getZ(); + virtual int getTypeId() const; + float getX(); + float getY(); + float getZ(); - private: - float mX; - float mY; - float mZ; + private: + float mX; + float mY; + float mZ; -}; + }; } #endif diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 71159b94bf..38d913f5fb 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -1,8 +1,8 @@ #include "aiwander.hpp" #include <iostream> -MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle): - mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(Idle) +MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> idle): + mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle) { } @@ -39,7 +39,5 @@ int MWMechanics::AiWander::getTypeId() const int MWMechanics::AiWander::getIdle(int index) const { - if(index < 0 || (uint)index > mIdle.size()) - return -1; return mIdle.at(index); } diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index 64168042ca..6b53390a1f 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -7,28 +7,28 @@ namespace MWMechanics { -class AiWander : public AiPackage -{ -public: + class AiWander : public AiPackage + { + public: - AiWander(int distance, int duration, int timeOfDay,std::vector<int> Idle); - virtual AiPackage *clone() const; - virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? - virtual int getTypeId() const; - ///< 0: Wander + AiWander(int distance, int duration, int timeOfDay,std::vector<int> idle); + virtual AiPackage *clone() const; + virtual bool execute (const MWWorld::Ptr& actor); + ///< \return Package completed? + virtual int getTypeId() const; + ///< 0: Wander - int getDistance() const; - int getDuration()const; - int getTimeOfDay()const; - int getIdle(int index) const; + int getDistance() const; + int getDuration()const; + int getTimeOfDay()const; + int getIdle(int index) const; -private: - int mDistance; - int mDuration; - int mTimeOfDay; - std::vector<int> mIdle; -}; -} + private: + int mDistance; + int mDuration; + int mTimeOfDay; + std::vector<int> mIdle; + }; + } #endif // AIWANDER_H From dc67a547b0a938b3c2fab948ed3998f74bc1b5b9 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 16 Nov 2012 19:34:09 +0100 Subject: [PATCH 243/255] global map explored overlay --- apps/openmw/mwgui/windowmanagerimp.cpp | 2 +- apps/openmw/mwrender/globalmap.cpp | 66 +++++++++++--------------- apps/openmw/mwrender/player.cpp | 1 - 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 39a217f6f6..376eca88d3 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -624,7 +624,7 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell) name = getGameSettingString("sDefaultCellname", "Wilderness"); } - mMap->cellExplored(cell->cell->getGridX(), cell->cell->getGridY()); + mMap->cellExplored(cell->mCell->getGridX(), cell->mCell->getGridY()); mMap->setCellName( name ); mHud->setCellName( name ); diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 27b307bff5..3faeb64071 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -1,6 +1,7 @@ #include "globalmap.hpp" #include <boost/filesystem.hpp> +#include <boost/lexical_cast.hpp> #include <OgreImage.h> #include <OgreTextureManager.h> @@ -159,13 +160,30 @@ namespace MWRender //image.save (mCacheDir + "/GlobalMap.png"); tex = Ogre::TextureManager::getSingleton ().createManual ("GlobalMap.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::TEX_TYPE_2D, mWidth, mHeight, 0, Ogre::PF_B8G8R8, Ogre::TU_DEFAULT); + Ogre::TEX_TYPE_2D, mWidth, mHeight, 0, Ogre::PF_B8G8R8, Ogre::TU_STATIC); tex->loadImage(image); } else tex = Ogre::TextureManager::getSingleton ().getByName ("GlobalMap.png"); tex->load(); + + + + + mOverlayTexture = Ogre::TextureManager::getSingleton().createManual("GlobalMapOverlay", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, + Ogre::TEX_TYPE_2D, mWidth, mHeight, 0, Ogre::PF_A8B8G8R8, Ogre::TU_DYNAMIC_WRITE_ONLY); + + + std::vector<Ogre::uint32> buffer; + buffer.resize(mWidth * mHeight); + + // initialize to (0, 0, 0, 0) + for (int p=0; p<mWidth * mHeight; ++p) + buffer[p] = 0; + + memcpy(mOverlayTexture->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), &buffer[0], mWidth*mHeight*4); + mOverlayTexture->getBuffer()->unlock(); } void GlobalMap::worldPosToImageSpace(float x, float z, float& imageX, float& imageY) @@ -185,44 +203,18 @@ namespace MWRender void GlobalMap::exploreCell(int cellX, int cellY) { - mExploredCells.push_back(std::make_pair(cellX, cellY)); - int width = mMaxX-mMinX+1; - int height = mMaxY-mMinY+1; + float originX = (cellX - mMinX) * 24; + // NB y + 1, because we want the top left corner, not bottom left where the origin of the cell is + float originY = mHeight - (cellY+1 - mMinY) * 24; - if (mOverlayTexture.isNull()) - { - mOverlayTexture = Ogre::TextureManager::getSingleton().createManual("GlobalMapOverlay", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, - Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8B8G8R8, Ogre::TU_DYNAMIC_WRITE_ONLY); - } + if (cellX > mMaxX || cellX < mMinX || cellY > mMaxY || cellY < mMinY) + return; - for (int x = mMinX; x <= mMaxX; ++x) - { - for (int y = mMinY; y <= mMaxY; ++y) - { - unsigned char r,g,b,a; - r = 0; - g = 0; - b = 0; - if (std::find(mExploredCells.begin(), mExploredCells.end(), std::make_pair(x, y)) != mExploredCells.end()) - a = 0; - else - a = 128; - int texelX = (x-mMinX); - int texelY = (height-1) - (y-mMinY); + Ogre::TexturePtr localMapTexture = Ogre::TextureManager::getSingleton().getByName("Cell_" + + boost::lexical_cast<std::string>(cellX) + "_" + boost::lexical_cast<std::string>(cellY)); - assert( static_cast<unsigned int>(texelY * width * 4 + texelX * 4+3) < mExploredBuffer.size()); - mExploredBuffer[texelY * width * 4 + texelX * 4] = r; - mExploredBuffer[texelY * width * 4 + texelX * 4+1] = g; - mExploredBuffer[texelY * width * 4 + texelX * 4+2] = b; - mExploredBuffer[texelY * width * 4 + texelX * 4+3] = a; - } - } - - Ogre::Image image; - image.loadDynamicImage(&mExploredBuffer[0], width, height, Ogre::PF_A8B8G8R8); - - memcpy(mOverlayTexture->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD), - &mExploredBuffer[0], width*height*4); - mOverlayTexture->getBuffer()->unlock(); + if (!localMapTexture.isNull()) + mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,1024, 1024), + Ogre::Image::Box(originX,originY,originX+24,originY+24)); } } diff --git a/apps/openmw/mwrender/player.cpp b/apps/openmw/mwrender/player.cpp index 409095a069..0e4c76b0ed 100644 --- a/apps/openmw/mwrender/player.cpp +++ b/apps/openmw/mwrender/player.cpp @@ -18,7 +18,6 @@ namespace MWRender : mCamera(camera), mPlayerNode(node), mCameraNode(mPlayerNode->createChildSceneNode()), - mAnimation(0), mFirstPersonView(true), mPreviewMode(false), mFreeLook(true), From a092deaee87bb98200af1e19f26bdb20b8170b58 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 16 Nov 2012 20:28:20 +0100 Subject: [PATCH 244/255] various fixes --- apps/openmw/mwmechanics/aiactivate.cpp | 4 ++-- apps/openmw/mwmechanics/aiactivate.hpp | 6 +++--- apps/openmw/mwmechanics/aiescort.cpp | 27 +++----------------------- apps/openmw/mwmechanics/aiescort.hpp | 11 +++-------- apps/openmw/mwmechanics/aifollow.cpp | 4 ++-- apps/openmw/mwmechanics/aifollow.hpp | 6 +++--- apps/openmw/mwmechanics/aitravel.cpp | 18 ++--------------- apps/openmw/mwmechanics/aitravel.hpp | 4 ---- apps/openmw/mwmechanics/aiwander.cpp | 22 +-------------------- apps/openmw/mwmechanics/aiwander.hpp | 11 +++-------- 10 files changed, 22 insertions(+), 91 deletions(-) diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index 464b30c7c6..b94c8c2599 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -1,8 +1,8 @@ #include "aiactivate.hpp" #include <iostream> -MWMechanics::AiActivate::AiActivate(const std::string &objectID): -mObjectID(objectID) +MWMechanics::AiActivate::AiActivate(const std::string &objectId) +: mObjectId(objectId) { } MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const diff --git a/apps/openmw/mwmechanics/aiactivate.hpp b/apps/openmw/mwmechanics/aiactivate.hpp index 5744cb25b3..7f3d4016dc 100644 --- a/apps/openmw/mwmechanics/aiactivate.hpp +++ b/apps/openmw/mwmechanics/aiactivate.hpp @@ -7,17 +7,17 @@ namespace MWMechanics { - class AiActivate : AiPackage + class AiActivate : public AiPackage { public: - AiActivate(const std::string &objectID); + AiActivate(const std::string &objectId); virtual AiActivate *clone() const; virtual bool execute (const MWWorld::Ptr& actor); ///< \return Package completed? virtual int getTypeId() const; private: - std::string mObjectID; + std::string mObjectId; }; } #endif // GAME_MWMECHANICS_AIACTIVATE_H diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 9f170ef6eb..27cd9095dc 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -1,10 +1,11 @@ #include "aiescort.hpp" #include <iostream> -MWMechanics::AiEscort::AiEscort(const std::string &actorID,int duration, float x, float y, float z): -mActorID(actorID), mDuration(duration), mX(x), mY(y), mZ(z) +MWMechanics::AiEscort::AiEscort(const std::string &actorId,int duration, float x, float y, float z) +: mActorId(actorId), mX(x), mY(y), mZ(z), mDuration(duration) { } + MWMechanics::AiEscort *MWMechanics::AiEscort::clone() const { return new AiEscort(*this); @@ -21,25 +22,3 @@ int MWMechanics::AiEscort::getTypeId() const return 2; } -float MWMechanics::AiEscort::getX() -{ - return mX; -} -float MWMechanics::AiEscort::getY() -{ - return mY; -} -float MWMechanics::AiEscort::getZ() -{ - return mZ; -} - -std::string MWMechanics::AiEscort::getActorID() -{ - return mActorID; -} - -int MWMechanics::AiEscort::getDuration() -{ - return mDuration; -} diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp index 4bd3f4b220..fef70f508e 100644 --- a/apps/openmw/mwmechanics/aiescort.hpp +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -9,21 +9,16 @@ namespace MWMechanics class AiEscort : public AiPackage { public: - AiEscort(const std::string &actorID,int duration, float x, float y, float z); + AiEscort(const std::string &actorId,int duration, float x, float y, float z); virtual AiEscort *clone() const; virtual bool execute (const MWWorld::Ptr& actor); - ///< \return Package completed? + ///< \return Package completed? virtual int getTypeId() const; - float getX(); - float getY(); - float getZ(); - std::string getActorID(); - int getDuration(); private: - std::string mActorID; + std::string mActorId; float mX; float mY; float mZ; diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index 6478544bc1..3fee6d98c3 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -1,8 +1,8 @@ #include "aifollow.hpp" #include <iostream> -MWMechanics::AiFollow::AiFollow(const std::string &actorID,float duration, float x, float y, float z): -mActorID(actorID), mDuration(duration), mX(x), mY(y), mZ(z) +MWMechanics::AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z) +: mDuration(duration), mX(x), mY(y), mZ(z), mActorId(actorId) { } MWMechanics::AiFollow *MWMechanics::AiFollow::clone() const diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp index 079c3c3810..ded13d7800 100644 --- a/apps/openmw/mwmechanics/aifollow.hpp +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -7,10 +7,10 @@ namespace MWMechanics { - class AiFollow : AiPackage + class AiFollow : public AiPackage { public: - AiFollow(const std::string &ActorID,float duration, float X, float Y, float Z); + AiFollow(const std::string &ActorId,float duration, float X, float Y, float Z); virtual AiFollow *clone() const; virtual bool execute (const MWWorld::Ptr& actor); ///< \return Package completed? @@ -21,7 +21,7 @@ namespace MWMechanics float mX; float mY; float mZ; - std::string mActorID; + std::string mActorId; }; } #endif diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index d07d302284..897dd17480 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -1,8 +1,8 @@ #include "aitravel.hpp" #include <iostream> -MWMechanics::AiTravel::AiTravel(float x, float y, float z): -mX(x),mY(y),mZ(z) +MWMechanics::AiTravel::AiTravel(float x, float y, float z) +: mX(x),mY(y),mZ(z) { } @@ -22,18 +22,4 @@ int MWMechanics::AiTravel::getTypeId() const return 1; } -float MWMechanics::AiTravel::getX() -{ - return mX; -} - -float MWMechanics::AiTravel::getY() -{ - return mY; -} - -float MWMechanics::AiTravel::getZ() -{ - return mZ; -} diff --git a/apps/openmw/mwmechanics/aitravel.hpp b/apps/openmw/mwmechanics/aitravel.hpp index 813ba81ebc..1c6abbf279 100644 --- a/apps/openmw/mwmechanics/aitravel.hpp +++ b/apps/openmw/mwmechanics/aitravel.hpp @@ -15,10 +15,6 @@ namespace MWMechanics ///< \return Package completed? virtual int getTypeId() const; - float getX(); - float getY(); - float getZ(); - private: float mX; diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 38d913f5fb..e9db6d212a 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -1,26 +1,11 @@ #include "aiwander.hpp" #include <iostream> -MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay,std::vector<int> idle): +MWMechanics::AiWander::AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle): mDistance(distance), mDuration(duration), mTimeOfDay(timeOfDay), mIdle(idle) { } -int MWMechanics::AiWander::getDistance() const -{ - return mDistance; -} - -int MWMechanics::AiWander::getDuration() const -{ - return mDuration; -} - -int MWMechanics::AiWander::getTimeOfDay() const -{ - return mTimeOfDay; -} - MWMechanics::AiPackage * MWMechanics::AiWander::clone() const { return new AiWander(*this); @@ -36,8 +21,3 @@ int MWMechanics::AiWander::getTypeId() const { return 0; } - -int MWMechanics::AiWander::getIdle(int index) const -{ - return mIdle.at(index); -} diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index 6b53390a1f..a71858febc 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -11,24 +11,19 @@ namespace MWMechanics { public: - AiWander(int distance, int duration, int timeOfDay,std::vector<int> idle); + AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle); virtual AiPackage *clone() const; virtual bool execute (const MWWorld::Ptr& actor); ///< \return Package completed? virtual int getTypeId() const; ///< 0: Wander - int getDistance() const; - int getDuration()const; - int getTimeOfDay()const; - int getIdle(int index) const; - private: int mDistance; int mDuration; - int mTimeOfDay; + int mTimeOfDay; std::vector<int> mIdle; }; } -#endif // AIWANDER_H +#endif From 948a4b723d9778039dc8cbf3d2f3985df3304846 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Fri, 16 Nov 2012 20:36:03 +0100 Subject: [PATCH 245/255] updated credits.txt --- credits.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/credits.txt b/credits.txt index c9f98861c2..4633dbba1b 100644 --- a/credits.txt +++ b/credits.txt @@ -27,6 +27,7 @@ Jason Hooks (jhooks) Karl-Felix Glatzer (k1ll) Leon Saunders (emoose) Lukasz Gromanowski (lgro) +Marcin Hulist (Gohan) Michael Mc Donnell Michael Papageorgiou (werdanith) Nikolay Kasyanov (corristo) From f5355e3e9275e53f6c2e9c0ce0f460d1f5312bac Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Fri, 16 Nov 2012 22:26:00 +0100 Subject: [PATCH 246/255] 512x512 map, slightly faster --- apps/openmw/mwrender/globalmap.cpp | 16 ++++++++++++++-- apps/openmw/mwrender/localmap.hpp | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index 3faeb64071..072015f9a8 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -213,8 +213,20 @@ namespace MWRender Ogre::TexturePtr localMapTexture = Ogre::TextureManager::getSingleton().getByName("Cell_" + boost::lexical_cast<std::string>(cellX) + "_" + boost::lexical_cast<std::string>(cellY)); - if (!localMapTexture.isNull()) - mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,1024, 1024), + // mipmap version - can't get ogre to generate automips.. + /*if (!localMapTexture.isNull()) + { + assert(localMapTexture->getBuffer(0, 4)->getWidth() == 64); // 1024 / 2^4 + + mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(0, 4), Ogre::Image::Box(0,0,64, 64), Ogre::Image::Box(originX,originY,originX+24,originY+24)); + }*/ + + if (!localMapTexture.isNull()) + { + + mOverlayTexture->getBuffer()->blit(localMapTexture->getBuffer(), Ogre::Image::Box(0,0,512,512), + Ogre::Image::Box(originX,originY,originX+24,originY+24)); + } } } diff --git a/apps/openmw/mwrender/localmap.hpp b/apps/openmw/mwrender/localmap.hpp index ede221d943..1aedf13255 100644 --- a/apps/openmw/mwrender/localmap.hpp +++ b/apps/openmw/mwrender/localmap.hpp @@ -74,7 +74,7 @@ namespace MWRender MWRender::RenderingManager* mRenderingManager; // 1024*1024 pixels for a cell - static const int sMapResolution = 1024; + static const int sMapResolution = 512; // the dynamic texture is a bottleneck, so don't set this too high static const int sFogOfWarResolution = 32; From 82ea547ce4e6f9c7245aca1e87cdca7dbf819411 Mon Sep 17 00:00:00 2001 From: eduard <eduard@eduard-iMac.(none)> Date: Sat, 17 Nov 2012 18:17:08 +0100 Subject: [PATCH 247/255] Failed action --- apps/openmw/CMakeLists.txt | 2 +- apps/openmw/mwclass/container.cpp | 6 +++--- apps/openmw/mwclass/door.cpp | 8 ++++---- apps/openmw/mwclass/light.cpp | 3 ++- apps/openmw/mwworld/failedaction.cpp | 24 ++++++++++++++++++++++++ apps/openmw/mwworld/failedaction.hpp | 21 +++++++++++++++++++++ 6 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 apps/openmw/mwworld/failedaction.cpp create mode 100644 apps/openmw/mwworld/failedaction.hpp diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 538f63dc96..67533cf4bf 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -50,7 +50,7 @@ add_openmw_dir (mwsound add_openmw_dir (mwworld refdata worldimp physicssystem scene globals class action nullaction actionteleport - containerstore actiontalk actiontake manualref player cellfunctors + containerstore actiontalk actiontake manualref player cellfunctors failedaction cells localscripts customdata weather inventorystore ptr actionopen actionread actionequip timestamp actionalchemy cellstore actionapply actioneat ) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 237f451f33..0ebf6491d4 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -8,7 +8,7 @@ #include "../mwbase/windowmanager.hpp" #include "../mwworld/ptr.hpp" -#include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/containerstore.hpp" #include "../mwworld/customdata.hpp" #include "../mwworld/cellstore.hpp" @@ -130,7 +130,7 @@ namespace MWClass { // Trap activation goes here std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; return action; @@ -138,7 +138,7 @@ namespace MWClass } else { - boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index f944391e12..63bd8fba0b 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -10,6 +10,7 @@ #include "../mwworld/player.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/actionteleport.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -111,8 +112,7 @@ namespace MWClass // Trap activation std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction); - + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; @@ -134,7 +134,7 @@ namespace MWClass else { // another NPC or a creature is using the door - return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); + return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction()); } } else @@ -153,7 +153,7 @@ namespace MWClass else { // locked, and we can't open. - boost::shared_ptr<MWWorld::Action> action(new MWWorld::NullAction); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 6ae9ed6615..7af31cc2c0 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -12,6 +12,7 @@ #include "../mwworld/actiontake.hpp" #include "../mwworld/actionequip.hpp" #include "../mwworld/nullaction.hpp" +#include "../mwworld/failedaction.hpp" #include "../mwworld/inventorystore.hpp" #include "../mwworld/cellstore.hpp" #include "../mwworld/physicssystem.hpp" @@ -92,7 +93,7 @@ namespace MWClass ptr.get<ESM::Light>(); if (!(ref->base->mData.mFlags & ESM::Light::Carry)) - return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction); + return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction()); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr)); diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp new file mode 100644 index 0000000000..78842820b5 --- /dev/null +++ b/apps/openmw/mwworld/failedaction.cpp @@ -0,0 +1,24 @@ +#include "failedaction.hpp" +#include "../mwbase/world.hpp" + + +namespace MWWorld +{ + FailedAction::FailedAction (const std::string& msg) : Action (false) + { + message = msg; + } + + FailedAction::FailedAction () : Action (false) + { + + } + + void FailedAction::executeImp (const Ptr& actor) + { + if ( actor.getRefData().getHandle()=="player" and not(message.empty())) + { + //return a message here + } + } +} diff --git a/apps/openmw/mwworld/failedaction.hpp b/apps/openmw/mwworld/failedaction.hpp new file mode 100644 index 0000000000..21df65c48a --- /dev/null +++ b/apps/openmw/mwworld/failedaction.hpp @@ -0,0 +1,21 @@ +#ifndef GAME_MWWORLD_FAILEDACTION_H +#define GAME_MWWORLD_FAILEDACTION_H + +#include "action.hpp" +#include "ptr.hpp" + +namespace MWWorld +{ + class FailedAction : public Action + { + std::string message; + + virtual void executeImp (const Ptr& actor); + + public: + FailedAction (const std::string& message); + FailedAction (); + }; +} + +#endif \ No newline at end of file From 693eeabecaddcf690f0a5c5c387be92b4a63d3c2 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Mon, 19 Nov 2012 13:55:26 +0100 Subject: [PATCH 248/255] shiny: fix GLSL texture units when shaders were disabled --- apps/openmw/mwgui/map_window.cpp | 2 -- extern/shiny/CMakeLists.txt | 3 +++ extern/shiny/Main/MaterialInstance.cpp | 8 +++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwgui/map_window.cpp b/apps/openmw/mwgui/map_window.cpp index ef67037651..0a26ebb8f4 100644 --- a/apps/openmw/mwgui/map_window.cpp +++ b/apps/openmw/mwgui/map_window.cpp @@ -266,8 +266,6 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager, const std::string& mGlobalMapRender = new MWRender::GlobalMap(cacheDir); mGlobalMapRender->render(); - mGlobalMapRender->exploreCell(0,0); - getWidget(mLocalMap, "LocalMap"); getWidget(mGlobalMap, "GlobalMap"); getWidget(mGlobalMapImage, "GlobalMapImage"); diff --git a/extern/shiny/CMakeLists.txt b/extern/shiny/CMakeLists.txt index c27850ed65..603336413e 100644 --- a/extern/shiny/CMakeLists.txt +++ b/extern/shiny/CMakeLists.txt @@ -70,3 +70,6 @@ endif() link_directories(${CMAKE_CURRENT_BINARY_DIR}) + +set(SHINY_LIBRARY ${SHINY_LIBRARY} PARENT_SCOPE) +set(SHINY_OGREPLATFORM_LIBRARY ${SHINY_OGREPLATFORM_LIBRARY} PARENT_SCOPE) diff --git a/extern/shiny/Main/MaterialInstance.cpp b/extern/shiny/Main/MaterialInstance.cpp index 3abc781f61..0f8bcdda78 100644 --- a/extern/shiny/Main/MaterialInstance.cpp +++ b/extern/shiny/Main/MaterialInstance.cpp @@ -72,6 +72,8 @@ namespace sh allowFixedFunction = retrieveValue<BooleanValue>(getProperty("allow_fixed_function"), NULL).get(); } + bool useShaders = mShadersEnabled || !allowFixedFunction; + // get passes of the top-most parent PassVector passes = getPasses(); if (passes.size() == 0) @@ -91,7 +93,7 @@ namespace sh // create or retrieve shaders bool hasVertex = it->hasProperty("vertex_program"); bool hasFragment = it->hasProperty("fragment_program"); - if (mShadersEnabled || !allowFixedFunction) + if (useShaders) { it->setContext(context); it->mShaderProperties.setContext(context); @@ -144,7 +146,7 @@ namespace sh bool foundVertex = std::find(usedTextureSamplersVertex.begin(), usedTextureSamplersVertex.end(), texIt->getName()) != usedTextureSamplersVertex.end(); bool foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end(); if ( (foundVertex || foundFragment) - || (((!mShadersEnabled || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get())) + || (((!useShaders || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get())) { boost::shared_ptr<TextureUnitState> texUnit = pass->createTextureUnitState (); texIt->copyAll (texUnit.get(), context); @@ -152,7 +154,7 @@ namespace sh mTexUnits.push_back(texUnit); // set texture unit indices (required by GLSL) - if (mShadersEnabled && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL) + if (useShaders && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL) { pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i); From 4e4d15f8ac82d661f1403e9d2aa6883c579aa211 Mon Sep 17 00:00:00 2001 From: eduard <eduard@eduard-iMac.(none)> Date: Mon, 19 Nov 2012 21:04:49 +0100 Subject: [PATCH 249/255] Failed action --- apps/openmw/mwclass/container.cpp | 4 ++-- apps/openmw/mwclass/door.cpp | 6 +++--- apps/openmw/mwclass/light.cpp | 2 +- apps/openmw/mwworld/failedaction.cpp | 17 +++++++---------- apps/openmw/mwworld/failedaction.hpp | 3 +-- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index 0ebf6491d4..28c292dfe5 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -130,7 +130,7 @@ namespace MWClass { // Trap activation goes here std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; return action; @@ -138,7 +138,7 @@ namespace MWClass } else { - boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index 63bd8fba0b..f9a135f37f 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -112,7 +112,7 @@ namespace MWClass // Trap activation std::cout << "Activated trap: " << ptr.getCellRef().mTrap << std::endl; - boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction); action->setSound(trapActivationSound); ptr.getCellRef().mTrap = ""; @@ -134,7 +134,7 @@ namespace MWClass else { // another NPC or a creature is using the door - return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction()); + return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction); } } else @@ -153,7 +153,7 @@ namespace MWClass else { // locked, and we can't open. - boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction()); + boost::shared_ptr<MWWorld::Action> action(new MWWorld::FailedAction); action->setSound(lockedSound); return action; } diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 7af31cc2c0..71dfe683e6 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -93,7 +93,7 @@ namespace MWClass ptr.get<ESM::Light>(); if (!(ref->base->mData.mFlags & ESM::Light::Carry)) - return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction()); + return boost::shared_ptr<MWWorld::Action> (new MWWorld::FailedAction); boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionTake (ptr)); diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp index 78842820b5..8c64db69f3 100644 --- a/apps/openmw/mwworld/failedaction.cpp +++ b/apps/openmw/mwworld/failedaction.cpp @@ -1,24 +1,21 @@ #include "failedaction.hpp" #include "../mwbase/world.hpp" +#include "../mwbase/environment.hpp" +#include "../mwbase/windowmanager.hpp" + namespace MWWorld { - FailedAction::FailedAction (const std::string& msg) : Action (false) - { - message = msg; - } + FailedAction::FailedAction (const std::string& msg) : Action (false), message(msg) + { } - FailedAction::FailedAction () : Action (false) - { - - } void FailedAction::executeImp (const Ptr& actor) { - if ( actor.getRefData().getHandle()=="player" and not(message.empty())) + if ( actor.getRefData().getHandle()=="player" and !(message.empty())) { - //return a message here + MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>()); } } } diff --git a/apps/openmw/mwworld/failedaction.hpp b/apps/openmw/mwworld/failedaction.hpp index 21df65c48a..e736bfb63b 100644 --- a/apps/openmw/mwworld/failedaction.hpp +++ b/apps/openmw/mwworld/failedaction.hpp @@ -13,8 +13,7 @@ namespace MWWorld virtual void executeImp (const Ptr& actor); public: - FailedAction (const std::string& message); - FailedAction (); + FailedAction (const std::string& message = std::string()); }; } From 45176130632249963a075e4519d3fc1d5da56059 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Mon, 19 Nov 2012 21:38:04 +0100 Subject: [PATCH 250/255] updated credits.txt --- credits.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/credits.txt b/credits.txt index 4633dbba1b..063e9940aa 100644 --- a/credits.txt +++ b/credits.txt @@ -19,6 +19,7 @@ BrotherBrick Cory F. Cohen (cfcohen) Cris Mihalache (Mirceam) Douglas Diniz (Dgdiniz) +Eduard Cot (trombonecot) Eli2 gugus / gus Jacob Essex (Yacoby) From c8562d8442060fd7a94beb021fd1e4de43048b70 Mon Sep 17 00:00:00 2001 From: scrawl <scrawl@baseoftrash.de> Date: Tue, 20 Nov 2012 02:20:54 +0100 Subject: [PATCH 251/255] toggleCollisionBoxes actually does something useful now --- apps/openmw/mwbase/world.hpp | 3 ++- apps/openmw/mwrender/renderingmanager.cpp | 8 +++++++- apps/openmw/mwscript/docs/vmformat.txt | 1 + apps/openmw/mwscript/miscextensions.cpp | 24 +++++++++++++++++++++-- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 5416945e79..40ebde2464 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -65,7 +65,8 @@ namespace MWBase Render_CollisionDebug, Render_Wireframe, Render_Pathgrid, - Render_Compositors + Render_Compositors, + Render_BoundingBoxes }; struct DoorMarker diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 0e363f1703..5f1f1ad433 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -473,7 +473,13 @@ bool RenderingManager::toggleRenderMode(int mode) return false; } } - else //if (mode == MWWorld::World::Render_Compositors) + else if (mode == MWBase::World::Render_BoundingBoxes) + { + bool show = !mRendering.getScene()->getShowBoundingBoxes(); + mRendering.getScene()->showBoundingBoxes(show); + return show; + } + else //if (mode == MWBase::World::Render_Compositors) { return mCompositors->toggle(); } diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 5a939b5db0..fdc4f49742 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -221,5 +221,6 @@ op 0x20001a8: CommonDisease op 0x20001a9: CommonDisease, explicit reference op 0x20001aa: BlightDisease op 0x20001ab: BlightDisease, explicit reference +op 0x20001ac: ToggleCollisionBoxes opcodes 0x20001ac-0x3ffffff unused diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index 674548cd68..c09f0c860f 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -132,6 +132,24 @@ namespace MWScript } }; + + class OpToggleCollisionBoxes : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + InterpreterContext& context = + static_cast<InterpreterContext&> (runtime.getContext()); + + bool enabled = + MWBase::Environment::get().getWorld()->toggleRenderMode (MWBase::World::Render_BoundingBoxes); + + context.report (enabled ? + "Bounding Box Rendering -> On" : "Bounding Box Rendering -> Off"); + } + }; + class OpToggleWireframe : public Interpreter::Opcode0 { public: @@ -262,6 +280,7 @@ namespace MWScript const int opcodeUnlock = 0x200008c; const int opcodeUnlockExplicit = 0x200008d; const int opcodeToggleCollisionDebug = 0x2000132; + const int opcodeToggleCollisionBoxes = 0x20001ac; const int opcodeToggleWireframe = 0x200013b; const int opcodeFadeIn = 0x200013c; const int opcodeFadeOut = 0x200013d; @@ -280,9 +299,9 @@ namespace MWScript extensions.registerInstruction ("activate", "", opcodeActivate); extensions.registerInstruction ("lock", "/l", opcodeLock, opcodeLockExplicit); extensions.registerInstruction ("unlock", "", opcodeUnlock, opcodeUnlockExplicit); - extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionDebug); + extensions.registerInstruction ("togglecollisionboxes", "", opcodeToggleCollisionBoxes); extensions.registerInstruction ("togglecollisiongrid", "", opcodeToggleCollisionDebug); - extensions.registerInstruction ("tcb", "", opcodeToggleCollisionDebug); + extensions.registerInstruction ("tcb", "", opcodeToggleCollisionBoxes); extensions.registerInstruction ("tcg", "", opcodeToggleCollisionDebug); extensions.registerInstruction ("twf", "", opcodeToggleWireframe); extensions.registerInstruction ("togglewireframe", "", opcodeToggleWireframe); @@ -310,6 +329,7 @@ namespace MWScript interpreter.installSegment5 (opcodeUnlock, new OpUnlock<ImplicitRef>); interpreter.installSegment5 (opcodeUnlockExplicit, new OpUnlock<ExplicitRef>); interpreter.installSegment5 (opcodeToggleCollisionDebug, new OpToggleCollisionDebug); + interpreter.installSegment5 (opcodeToggleCollisionBoxes, new OpToggleCollisionBoxes); interpreter.installSegment5 (opcodeToggleWireframe, new OpToggleWireframe); interpreter.installSegment5 (opcodeFadeIn, new OpFadeIn); interpreter.installSegment5 (opcodeFadeOut, new OpFadeOut); From 9201baebf97afed41d9c3b82c2b97a48f4230be1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 22 Nov 2012 10:19:11 +0100 Subject: [PATCH 252/255] template fix --- apps/openmw/mwworld/store.cpp | 18 ------------------ apps/openmw/mwworld/store.hpp | 14 +++++++++++--- 2 files changed, 11 insertions(+), 21 deletions(-) delete mode 100644 apps/openmw/mwworld/store.cpp diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp deleted file mode 100644 index 5a6b6a7630..0000000000 --- a/apps/openmw/mwworld/store.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "store.hpp" - -namespace MWWorld -{ - template <> - void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id) { - mStatic.push_back(ESM::Dialogue()); - mStatic.back().mId = id; - mStatic.back().load(esm); - } - - template <> - void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id) { - mStatic.push_back(ESM::Script()); - mStatic.back().load(esm); - StringUtils::toLower(mStatic.back().mId); - } -} diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index a406a39de0..fd93f39f1e 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -203,10 +203,18 @@ namespace MWWorld }; template <> - void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id); + inline void Store<ESM::Dialogue>::load(ESM::ESMReader &esm, const std::string &id) { + mStatic.push_back(ESM::Dialogue()); + mStatic.back().mId = id; + mStatic.back().load(esm); + } template <> - void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id); + inline void Store<ESM::Script>::load(ESM::ESMReader &esm, const std::string &id) { + mStatic.push_back(ESM::Script()); + mStatic.back().load(esm); + StringUtils::toLower(mStatic.back().mId); + } template <> class Store<ESM::LandTexture> : public StoreBase @@ -347,7 +355,7 @@ namespace MWWorld typedef std::map<std::string, ESM::Cell> DynamicInt; typedef std::map<std::pair<int, int>, ESM::Cell> DynamicExt; - + DynamicInt mDynamicInt; DynamicExt mDynamicExt; From d684b3ae1150ff204f2052b994d9b1426e85b4b6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 22 Nov 2012 10:35:03 +0100 Subject: [PATCH 253/255] fixed getString function in NIF loader --- components/nif/nif_file.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/components/nif/nif_file.hpp b/components/nif/nif_file.hpp index a4eaa89906..23bccb0fe0 100644 --- a/components/nif/nif_file.hpp +++ b/components/nif/nif_file.hpp @@ -193,11 +193,12 @@ public: std::string getString(size_t length) { - std::string str; - str.resize(length); + std::vector<char> str (length+1, 0); + if(inp->read(&str[0], length) != length) - return std::string(); - return str.substr(0, str.find('\0')); + throw std::runtime_error ("string length in NIF file does not match"); + + return &str[0]; } std::string getString() { From 6643674b13e13b53361cd6a015a04655fff7c90d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 22 Nov 2012 17:23:25 +0100 Subject: [PATCH 254/255] ESM tool fix --- apps/esmtool/record.cpp | 115 ++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 62 deletions(-) diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index e26015970e..b5f97e979e 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -15,7 +15,7 @@ void printAIPackage(ESM::AIPackage p) std::cout << " Time of Day: " << (int)p.mWander.mTimeOfDay << std::endl; if (p.mWander.mUnk != 1) std::cout << " Unknown: " << (int)p.mWander.mUnk << std::endl; - + std::cout << " Idle: "; for (int i = 0; i != 8; i++) std::cout << (int)p.mWander.mIdle[i] << " "; @@ -28,7 +28,7 @@ void printAIPackage(ESM::AIPackage p) std::cout << " Travel Unknown: " << (int)p.mTravel.mUnk << std::endl; } else if (p.mType == ESM::AI_Follow || p.mType == ESM::AI_Escort) - { + { std::cout << " Follow Coordinates: (" << p.mTarget.mX << "," << p.mTarget.mY << "," << p.mTarget.mZ << ")" << std::endl; std::cout << " Duration: " << p.mTarget.mDuration << std::endl; @@ -43,7 +43,7 @@ void printAIPackage(ESM::AIPackage p) else { std::cout << " BadPackage: " << boost::format("0x%08x") % p.mType << std::endl; } - + if (p.mCellName != "") std::cout << " Cell Name: " << p.mCellName << std::endl; } @@ -51,13 +51,13 @@ void printAIPackage(ESM::AIPackage p) std::string ruleString(ESM::DialInfo::SelectStruct ss) { std::string rule = ss.mSelectRule; - + if (rule.length() < 5) return "INVALID"; - + char type = rule[1]; char indicator = rule[2]; - + std::string type_str = "INVALID"; std::string func_str = str(boost::format("INVALID=%s") % rule.substr(1,3)); int func; @@ -71,14 +71,14 @@ std::string ruleString(ESM::DialInfo::SelectStruct ss) func_str = ruleFunction(func); break; case '2': - if (indicator == 's') type_str = "Global short"; - else if (indicator == 'l') type_str = "Global long"; - else if (indicator == 'f') type_str = "Global float"; + if (indicator == 's') type_str = "Global short"; + else if (indicator == 'l') type_str = "Global long"; + else if (indicator == 'f') type_str = "Global float"; break; case '3': - if (indicator == 's') type_str = "Local short"; - else if (indicator == 'l') type_str = "Local long"; - else if (indicator == 'f') type_str = "Local float"; + if (indicator == 's') type_str = "Local short"; + else if (indicator == 'l') type_str = "Local long"; + else if (indicator == 'f') type_str = "Local float"; break; case '4': if (indicator == 'J') type_str = "Journal"; break; case '5': if (indicator == 'I') type_str = "Item type"; break; @@ -90,15 +90,15 @@ std::string ruleString(ESM::DialInfo::SelectStruct ss) case 'B': if (indicator == 'L') type_str = "Not Cell"; break; case 'C': if (indicator == 's') type_str = "Not Local"; break; } - + // Append the variable name to the function string if any. if (type != '1') func_str = rule.substr(5); - + // In the previous switch, we assumed that the second char was X // for all types not qual to one. If this wasn't true, go back to // the error message. if (type != '1' && rule[3] != 'X') - func_str = str(boost::format("INVALID=%s") % rule.substr(1,3)); + func_str = str(boost::format("INVALID=%s") % rule.substr(1,3)); char oper = rule[4]; std::string oper_str = "??"; @@ -117,8 +117,8 @@ std::string ruleString(ESM::DialInfo::SelectStruct ss) value_str = str(boost::format("%d") % ss.mI); else if (ss.mType == ESM::VT_Float) value_str = str(boost::format("%f") % ss.mF); - - std::string result = str(boost::format("%-12s %-32s %2s %s") + + std::string result = str(boost::format("%-12s %-32s %2s %s") % type_str % func_str % oper_str % value_str); return result; } @@ -136,7 +136,7 @@ void printEffectList(ESM::EffectList effects) << " (" << (int)eit->mSkill << ")" << std::endl; if (eit->mAttribute != -1) std::cout << " Attribute: " << attributeLabel(eit->mAttribute) - << " (" << (int)eit->mAttribute << ")" << std::endl; + << " (" << (int)eit->mAttribute << ")" << std::endl; std::cout << " Range: " << rangeTypeLabel(eit->mRange) << " (" << eit->mRange << ")" << std::endl; // Area is always zero if range type is "Self" @@ -412,7 +412,7 @@ void Record<ESM::Armor>::print() std::cout << " Weight: " << mData.mData.mWeight << std::endl; std::cout << " Value: " << mData.mData.mValue << std::endl; std::cout << " Health: " << mData.mData.mHealth << std::endl; - std::cout << " Armor: " << mData.mData.mArmor << std::endl; + std::cout << " Armor: " << mData.mData.mArmor << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; std::vector<ESM::PartReference>::iterator pit; for (pit = mData.mParts.mParts.begin(); pit != mData.mParts.mParts.end(); pit++) @@ -483,7 +483,7 @@ void Record<ESM::BirthSign>::print() std::cout << " Description: " << mData.mDescription << std::endl; std::vector<std::string>::iterator pit; for (pit = mData.mPowers.mList.begin(); pit != mData.mPowers.mList.end(); pit++) - std::cout << " Power: " << *pit << std::endl; + std::cout << " Power: " << *pit << std::endl; } template<> @@ -495,12 +495,12 @@ void Record<ESM::Cell>::print() if (mData.mRegion != "") std::cout << " Region: " << mData.mRegion << std::endl; std::cout << " Flags: " << cellFlags(mData.mData.mFlags) << std::endl; - + std::cout << " Coordinates: " << " (" << mData.getGridX() << "," << mData.getGridY() << ")" << std::endl; - - if (mData.mData.mFlags & ESM::Cell::Interior && - !(mData.mData.mFlags & ESM::Cell::QuasiEx)) + + if (mData.mData.mFlags & ESM::Cell::Interior && + !(mData.mData.mFlags & ESM::Cell::QuasiEx)) { std::cout << " Ambient Light Color: " << mData.mAmbi.mAmbient << std::endl; std::cout << " Sunlight Color: " << mData.mAmbi.mSunlight << std::endl; @@ -508,7 +508,7 @@ void Record<ESM::Cell>::print() std::cout << " Fog Density: " << mData.mAmbi.mFogDensity << std::endl; std::cout << " Water Level: " << mData.mWater << std::endl; } - else + else std::cout << " Map Color: " << boost::format("0x%08X") % mData.mMapColor << std::endl; std::cout << " Water Level Int: " << mData.mWaterInt << std::endl; std::cout << " NAM0: " << mData.mNAM0 << std::endl; @@ -530,7 +530,7 @@ void Record<ESM::Class>::print() << " (" << mData.mData.mSpecialization << ")" << std::endl; for (int i = 0; i != 5; i++) std::cout << " Major Skill: " << skillLabel(mData.mData.mSkills[i][0]) - << " (" << mData.mData.mSkills[i][0] << ")" << std::endl; + << " (" << mData.mData.mSkills[i][0] << ")" << std::endl; for (int i = 0; i != 5; i++) std::cout << " Minor Skill: " << skillLabel(mData.mData.mSkills[i][1]) << " (" << mData.mData.mSkills[i][1] << ")" << std::endl; @@ -573,7 +573,7 @@ void Record<ESM::Container>::print() std::cout << " Weight: " << mData.mWeight << std::endl; std::vector<ESM::ContItem>::iterator cit; for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) - std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount << " Item: " << cit->mItem.toString() << std::endl; } @@ -608,17 +608,17 @@ void Record<ESM::Creature>::print() std::cout << " Combat: " << mData.mData.mCombat << std::endl; std::cout << " Magic: " << mData.mData.mMagic << std::endl; std::cout << " Stealth: " << mData.mData.mStealth << std::endl; - std::cout << " Attack1: " << mData.mData.mAttack[0] + std::cout << " Attack1: " << mData.mData.mAttack[0] << "-" << mData.mData.mAttack[1] << std::endl; - std::cout << " Attack2: " << mData.mData.mAttack[2] + std::cout << " Attack2: " << mData.mData.mAttack[2] << "-" << mData.mData.mAttack[3] << std::endl; - std::cout << " Attack3: " << mData.mData.mAttack[4] + std::cout << " Attack3: " << mData.mData.mAttack[4] << "-" << mData.mData.mAttack[5] << std::endl; std::cout << " Gold: " << mData.mData.mGold << std::endl; std::vector<ESM::ContItem>::iterator cit; for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) - std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount << " Item: " << cit->mItem.toString() << std::endl; std::vector<std::string>::iterator sit; @@ -694,15 +694,15 @@ void Record<ESM::Faction>::print() if (mData.mRanks[i] != "") { std::cout << " Rank: " << mData.mRanks[i] << std::endl; - std::cout << " Attribute1 Requirement: " + std::cout << " Attribute1 Requirement: " << mData.mData.mRankData[i].mAttribute1 << std::endl; - std::cout << " Attribute2 Requirement: " + std::cout << " Attribute2 Requirement: " << mData.mData.mRankData[i].mAttribute2 << std::endl; std::cout << " One Skill at Level: " << mData.mData.mRankData[i].mSkill1 << std::endl; - std::cout << " Two Skills at Level: " + std::cout << " Two Skills at Level: " << mData.mData.mRankData[i].mSkill2 << std::endl; - std::cout << " Faction Reaction: " + std::cout << " Faction Reaction: " << mData.mData.mRankData[i].mFactReaction << std::endl; } std::vector<ESM::Faction::Reaction>::iterator rit; @@ -849,7 +849,7 @@ void Record<ESM::CreatureLevList>::print() std::cout << " Number of items: " << mData.mList.size() << std::endl; std::vector<ESM::LeveledListBase::LevelItem>::iterator iit; for (iit = mData.mList.begin(); iit != mData.mList.end(); iit++) - std::cout << " Creature: Level: " << iit->mLevel + std::cout << " Creature: Level: " << iit->mLevel << " Creature: " << iit->mId << std::endl; } @@ -1012,11 +1012,11 @@ void Record<ESM::NPC>::print() std::cout << " Disposition: " << (int)mData.mNpdt12.mDisposition << std::endl; std::cout << " Faction: " << (int)mData.mNpdt52.mFactionID << std::endl; std::cout << " Rank: " << (int)mData.mNpdt12.mRank << std::endl; - std::cout << " Unknown1: " + std::cout << " Unknown1: " << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown1) << std::endl; - std::cout << " Unknown2: " + std::cout << " Unknown2: " << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown2) << std::endl; - std::cout << " Unknown3: " + std::cout << " Unknown3: " << (unsigned int)((unsigned char)mData.mNpdt12.mUnknown3) << std::endl; std::cout << " Gold: " << (int)mData.mNpdt12.mGold << std::endl; } @@ -1038,9 +1038,9 @@ void Record<ESM::NPC>::print() std::cout << " Skills:" << std::endl; for (int i = 0; i != 27; i++) - std::cout << " " << skillLabel(i) << ": " - << (int)((unsigned char)mData.mNpdt52.mSkills[i]) << std::endl; - + std::cout << " " << skillLabel(i) << ": " + << (int)((unsigned char)mData.mNpdt52.mSkills[i]) << std::endl; + std::cout << " Health: " << mData.mNpdt52.mHealth << std::endl; std::cout << " Magicka: " << mData.mNpdt52.mMana << std::endl; std::cout << " Fatigue: " << mData.mNpdt52.mFatigue << std::endl; @@ -1050,9 +1050,9 @@ void Record<ESM::NPC>::print() std::vector<ESM::ContItem>::iterator cit; for (cit = mData.mInventory.mList.begin(); cit != mData.mInventory.mList.end(); cit++) - std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount + std::cout << " Inventory: Count: " << boost::format("%4d") % cit->mCount << " Item: " << cit->mItem.toString() << std::endl; - + std::vector<std::string>::iterator sit; for (sit = mData.mSpells.mList.begin(); sit != mData.mSpells.mList.end(); sit++) std::cout << " Spell: " << *sit << std::endl; @@ -1060,18 +1060,18 @@ void Record<ESM::NPC>::print() std::vector<ESM::NPC::Dest>::iterator dit; for (dit = mData.mTransport.begin(); dit != mData.mTransport.end(); dit++) { - std::cout << " Destination Position: " + std::cout << " Destination Position: " << boost::format("%12.3f") % dit->mPos.pos[0] << "," << boost::format("%12.3f") % dit->mPos.pos[1] << "," << boost::format("%12.3f") % dit->mPos.pos[2] << ")" << std::endl; - std::cout << " Destination Rotation: " + std::cout << " Destination Rotation: " << boost::format("%9.6f") % dit->mPos.rot[0] << "," << boost::format("%9.6f") % dit->mPos.rot[1] << "," - << boost::format("%9.6f") % dit->mPos.rot[2] << ")" << std::endl; + << boost::format("%9.6f") % dit->mPos.rot[2] << ")" << std::endl; if (dit->mCellName != "") std::cout << " Destination Cell: " << dit->mCellName << std::endl; } - + std::cout << " Artifical Intelligence: " << mData.mHasAI << std::endl; std::cout << " AI Hello:" << (int)mData.mAiData.mHello << std::endl; std::cout << " AI Fight:" << (int)mData.mAiData.mFight << std::endl; @@ -1104,7 +1104,7 @@ void Record<ESM::Pathgrid>::print() for (pit = mData.mPoints.begin(); pit != mData.mPoints.end(); pit++) { std::cout << " Point[" << i << "]:" << std::endl; - std::cout << " Coordinates: (" << pit->mX << "," + std::cout << " Coordinates: (" << pit->mX << "," << pit->mY << "," << pit->mZ << ")" << std::endl; std::cout << " Auto-Generated: " << (int)pit->mAutogenerated << std::endl; std::cout << " Connections: " << (int)pit->mConnectionNum << std::endl; @@ -1267,7 +1267,7 @@ void Record<ESM::Sound>::print() std::cout << " Sound: " << mData.mSound << std::endl; std::cout << " Volume: " << (int)mData.mData.mVolume << std::endl; if (mData.mData.mMinRange != 0 && mData.mData.mMaxRange != 0) - std::cout << " Range: " << (int)mData.mData.mMinRange << " - " + std::cout << " Range: " << (int)mData.mData.mMinRange << " - " << (int)mData.mData.mMaxRange << std::endl; } @@ -1308,7 +1308,7 @@ void Record<ESM::Weapon>::print() if (mData.mScript != "") std::cout << " Script: " << mData.mScript << std::endl; if (mData.mEnchant != "") - std::cout << " Enchantment: " << mData.mEnchant << std::endl; + std::cout << " Enchantment: " << mData.mEnchant << std::endl; std::cout << " Type: " << weaponTypeLabel(mData.mData.mType) << " (" << mData.mData.mType << ")" << std::endl; std::cout << " Flags: " << weaponFlags(mData.mData.mFlags) << std::endl; @@ -1319,23 +1319,14 @@ void Record<ESM::Weapon>::print() std::cout << " Reach: " << mData.mData.mReach << std::endl; std::cout << " Enchantment Points: " << mData.mData.mEnchant << std::endl; if (mData.mData.mChop[0] != 0 && mData.mData.mChop[1] != 0) - std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-" + std::cout << " Chop: " << (int)mData.mData.mChop[0] << "-" << (int)mData.mData.mChop[1] << std::endl; if (mData.mData.mSlash[0] != 0 && mData.mData.mSlash[1] != 0) std::cout << " Slash: " << (int)mData.mData.mSlash[0] << "-" << (int)mData.mData.mSlash[1] << std::endl; if (mData.mData.mThrust[0] != 0 && mData.mData.mThrust[1] != 0) - std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-" + std::cout << " Thrust: " << (int)mData.mData.mThrust[0] << "-" << (int)mData.mData.mThrust[1] << std::endl; } -template<> -void Record<ESM::CellRef>::print() -{ - std::cout << " Refnum: " << mData.mRefnum << std::endl; - std::cout << " ID: '" << mData.mRefID << "'\n"; - std::cout << " Owner: '" << mData.mOwner << "'\n"; - std::cout << " INTV: " << mData.mIntv << " NAM9: " << mData.mIntv << std::endl; -} - } // end namespace From d7af9fbec6919bf8e1be2b6a91bfa27532d285f1 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag <marc@zpages.de> Date: Thu, 22 Nov 2012 17:24:28 +0100 Subject: [PATCH 255/255] various fixes --- apps/openmw/mwdialogue/selectwrapper.cpp | 1 + apps/openmw/mwworld/failedaction.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwdialogue/selectwrapper.cpp b/apps/openmw/mwdialogue/selectwrapper.cpp index bba17bfd10..1462ee8ba2 100644 --- a/apps/openmw/mwdialogue/selectwrapper.cpp +++ b/apps/openmw/mwdialogue/selectwrapper.cpp @@ -6,6 +6,7 @@ #include <stdexcept> #include <algorithm> #include <sstream> +#include <iterator> namespace { diff --git a/apps/openmw/mwworld/failedaction.cpp b/apps/openmw/mwworld/failedaction.cpp index 8c64db69f3..ec763dba01 100644 --- a/apps/openmw/mwworld/failedaction.cpp +++ b/apps/openmw/mwworld/failedaction.cpp @@ -9,11 +9,11 @@ namespace MWWorld { FailedAction::FailedAction (const std::string& msg) : Action (false), message(msg) { } - - + + void FailedAction::executeImp (const Ptr& actor) { - if ( actor.getRefData().getHandle()=="player" and !(message.empty())) + if ( actor.getRefData().getHandle()=="player" && !(message.empty())) { MWBase::Environment::get().getWindowManager() ->messageBox(message, std::vector<std::string>()); }