From 0c461f4424a0912af405530878d559ebd376c3b8 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 9 May 2015 21:21:16 +1000 Subject: [PATCH 1/7] Add TopicInfos special conditions table. --- apps/opencs/model/world/columnbase.cpp | 3 + apps/opencs/model/world/columnbase.hpp | 3 + apps/opencs/model/world/columns.cpp | 21 + apps/opencs/model/world/columns.hpp | 7 +- apps/opencs/model/world/data.cpp | 13 + .../model/world/nestedcoladapterimp.cpp | 413 ++++++++++++++++++ .../model/world/nestedcoladapterimp.hpp | 25 ++ apps/opencs/view/doc/viewmanager.cpp | 4 +- 8 files changed, 487 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/columnbase.cpp b/apps/opencs/model/world/columnbase.cpp index 659954f481..cf125aa639 100644 --- a/apps/opencs/model/world/columnbase.cpp +++ b/apps/opencs/model/world/columnbase.cpp @@ -81,6 +81,9 @@ bool CSMWorld::ColumnBase::isId (Display display) Display_PartRefType, Display_AiPackageType, Display_YesNo, + Display_InfoCondFunc, + Display_InfoCondVar, + Display_InfoCondComp, Display_None }; diff --git a/apps/opencs/model/world/columnbase.hpp b/apps/opencs/model/world/columnbase.hpp index 71c22a9f07..2d2513774a 100644 --- a/apps/opencs/model/world/columnbase.hpp +++ b/apps/opencs/model/world/columnbase.hpp @@ -116,6 +116,9 @@ namespace CSMWorld Display_PartRefType, Display_AiPackageType, Display_YesNo, + Display_InfoCondFunc, + Display_InfoCondVar, + Display_InfoCondComp, //top level columns that nest other columns Display_NestedHeader diff --git a/apps/opencs/model/world/columns.cpp b/apps/opencs/model/world/columns.cpp index 9076aa0968..89ee6258b5 100644 --- a/apps/opencs/model/world/columns.cpp +++ b/apps/opencs/model/world/columns.cpp @@ -274,6 +274,11 @@ namespace CSMWorld { ColumnId_SkillImpact, "Skills" }, { ColumnId_InfoList, "Info List" }, + { ColumnId_InfoCondition, "Info Conditions" }, + { ColumnId_InfoCondFunc, "Function" }, + { ColumnId_InfoCondVar, "Func/Variable" }, + { ColumnId_InfoCondComp, "Comp" }, + { ColumnId_InfoCondValue, "Value" }, { ColumnId_OriginalCell, "Original Cell" }, { ColumnId_UseValue1, "Use value 1" }, @@ -502,6 +507,18 @@ namespace "No", "Yes", 0 }; + static const char *sInfoCondFunc[] = + { + " ", "Function", "Global", "Local", "Journal", + "Item", "Dead", "Not ID", "Not Faction", "Not Class", + "Not Race", "Not Cell", "Not Local", 0 + }; + + static const char *sInfoCondComp[] = + { + "!=", "<", "<=", "=", ">", ">=", 0 + }; + const char **getEnumNames (CSMWorld::Columns::ColumnId column) { switch (column) @@ -530,6 +547,10 @@ namespace case CSMWorld::Columns::ColumnId_PartRefType: return sPartRefType; case CSMWorld::Columns::ColumnId_AiPackageType: return sAiPackageType; case CSMWorld::Columns::ColumnId_AiWanderRepeat: return sAiWanderRepeat; + case CSMWorld::Columns::ColumnId_InfoCondFunc: return sInfoCondFunc; + // FIXME: don't have dynamic value enum delegate, use Display_String for now + //case CSMWorld::Columns::ColumnId_InfoCond: return sInfoCond; + case CSMWorld::Columns::ColumnId_InfoCondComp: return sInfoCondComp; default: return 0; } diff --git a/apps/opencs/model/world/columns.hpp b/apps/opencs/model/world/columns.hpp index b87f6c53d0..f971f3fd89 100644 --- a/apps/opencs/model/world/columns.hpp +++ b/apps/opencs/model/world/columns.hpp @@ -264,8 +264,13 @@ namespace CSMWorld ColumnId_SkillImpact = 240, // impact from magic effects ColumnId_InfoList = 241, + ColumnId_InfoCondition = 242, + ColumnId_InfoCondFunc = 243, + ColumnId_InfoCondVar = 244, + ColumnId_InfoCondComp = 245, + ColumnId_InfoCondValue = 246, - ColumnId_OriginalCell = 242, + ColumnId_OriginalCell = 247, // Allocated to a separate value range, so we don't get a collision should we ever need // to extend the number of use values. diff --git a/apps/opencs/model/world/data.cpp b/apps/opencs/model/world/data.cpp index fc4532fb0e..e2fab0a25b 100644 --- a/apps/opencs/model/world/data.cpp +++ b/apps/opencs/model/world/data.cpp @@ -242,6 +242,19 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, const ResourcesManager& resourc mTopicInfos.addAdapter (std::make_pair(&mTopicInfos.getColumn(index), new InfoListAdapter ())); mTopicInfos.getNestableColumn(index)->addColumn( new NestedChildColumn (Columns::ColumnId_ScriptText, ColumnBase::Display_ScriptLines)); + // Special conditions + mTopicInfos.addColumn (new NestedParentColumn (Columns::ColumnId_InfoCondition)); + index = mTopicInfos.getColumns()-1; + mTopicInfos.addAdapter (std::make_pair(&mTopicInfos.getColumn(index), new InfoConditionAdapter ())); + mTopicInfos.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_InfoCondFunc, ColumnBase::Display_InfoCondFunc)); + // FIXME: don't have dynamic value enum delegate, use Display_String for now + mTopicInfos.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_InfoCondVar, ColumnBase::Display_String)); + mTopicInfos.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_InfoCondComp, ColumnBase::Display_InfoCondComp)); + mTopicInfos.getNestableColumn(index)->addColumn( + new NestedChildColumn (Columns::ColumnId_Value, ColumnBase::Display_Var)); mJournalInfos.addColumn (new StringIdColumn (true)); mJournalInfos.addColumn (new RecordStateColumn); diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index d29155a478..9cd1a0a3b6 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -528,4 +528,417 @@ namespace CSMWorld { return 1; // fixed at size 1 } + + // ESM::DialInfo::SelectStruct.mSelectRule + // 012345... + // ^^^ ^^ + // ||| || + // ||| |+------------- condition variable string + // ||| +-------------- comparison type, ['0'..'5']; e.g. !=, <, >=, etc + // ||+---------------- function index (encoded, where function == '1') + // |+----------------- function, ['1'..'C']; e.g. Global, Local, Not ID, etc + // +------------------ unknown + // + InfoConditionAdapter::InfoConditionAdapter () {} + + void InfoConditionAdapter::addRow(Record& record, int position) const + { + Info info = record.get(); + + std::vector& conditions = info.mSelects; + + // blank row + ESM::DialInfo::SelectStruct condStruct; + condStruct.mSelectRule = "00000"; + condStruct.mValue = ESM::Variant(); + + conditions.insert(conditions.begin()+position, condStruct); + + record.setModified (info); + } + + void InfoConditionAdapter::removeRow(Record& record, int rowToRemove) const + { + Info info = record.get(); + + std::vector& conditions = info.mSelects; + + if (rowToRemove < 0 || rowToRemove >= static_cast (conditions.size())) + throw std::runtime_error ("index out of range"); + + conditions.erase(conditions.begin()+rowToRemove); + + record.setModified (info); + } + + void InfoConditionAdapter::setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const + { + Info info = record.get(); + + info.mSelects = + static_cast >&>(nestedTable).mNestedTable; + + record.setModified (info); + } + + NestedTableWrapperBase* InfoConditionAdapter::table(const Record& record) const + { + // deleted by dtor of NestedTableStoring + return new NestedTableWrapper >(record.get().mSelects); + } + + // See the mappings in MWDialogue::SelectWrapper::getArgument + // from ESM::Attribute, ESM::Skill and MWMechanics::CreatureStats (for AI) + static const std::map sEncToInfoFunc = + { + { "00", "Rank Low" }, + { "01", "Rank High" }, + { "02", "Rank Requirement" }, + { "03", "Reputation" }, + { "04", "Health Percent" }, + { "05", "PC Reputation" }, + { "06", "PC Level" }, + { "07", "PC Health Percent" }, + { "08", "PC Magicka" }, // dynamic stat + { "09", "PC Fatigue" }, // dynamic stat + { "10", "PC Strength" }, // attrib + { "11", "PC Block" }, + { "12", "PC Armoror" }, + { "13", "PC Medium Armor" }, + { "14", "PC Heavy Armor" }, + { "15", "PC Blunt Weapon" }, + { "16", "PC Long Blade" }, + { "17", "PC Axe" }, + { "18", "PC Spear" }, + { "19", "PC Athletics" }, + { "20", "PC Enchant" }, + { "21", "PC Destruction" }, + { "22", "PC Alteration" }, + { "23", "PC Illusion" }, + { "24", "PC Conjuration" }, + { "25", "PC Mysticism" }, + { "26", "PC Restoration" }, + { "27", "PC Alchemy" }, + { "28", "PC Unarmored" }, + { "29", "PC Security" }, + { "30", "PC Sneak" }, + { "31", "PC Acrobatics" }, + { "32", "PC Light Armor" }, + { "33", "PC Short Blade" }, + { "34", "PC Marksman" }, + { "35", "PC Merchantile" }, + { "36", "PC Speechcraft" }, + { "37", "PC Hand To Hand" }, + { "38", "PC Sex" }, + { "39", "PC Expelled" }, + { "40", "PC Common Disease" }, + { "41", "PC Blight Disease" }, + { "42", "PC Clothing Modifier" }, + { "43", "PC Crime Level" }, + { "44", "Same Sex" }, + { "45", "Same Race" }, + { "46", "Same Faction" }, + { "47", "Faction Rank Difference" }, + { "48", "Detected" }, + { "49", "Alarmed" }, + { "50", "Choice" }, + { "51", "PC Intelligence" }, // attrib + { "52", "PC Willpower" }, // attrib + { "53", "PC Agility" }, // attrib + { "54", "PC Speed" }, // attrib + { "55", "PC Endurance" }, // attrib + { "56", "PC Personality" }, // attrib + { "57", "PC Luck" }, // attrib + { "58", "PC Corpus" }, + { "59", "Weather" }, + { "60", "PC Vampire" }, + { "61", "Level" }, + { "62", "Attacked" }, + { "63", "Talked To PC" }, + { "64", "PC Health" }, // dynamic stat + { "65", "Creature Target" }, + { "66", "Friend Hit" }, + { "67", "Fight" }, // AI + { "68", "Hello" }, // AI + { "69", "Alarm" }, // AI + { "70", "Flee" }, // AI + { "71", "Should Attack" }, + { "72", "Werewolf" }, + { "73", "PC Werewolf Kills" } + }; + + QVariant InfoConditionAdapter::getData(const Record& record, + int subRowIndex, int subColIndex) const + { + Info info = record.get(); + + std::vector& conditions = info.mSelects; + + if (subRowIndex < 0 || subRowIndex >= static_cast (conditions.size())) + throw std::runtime_error ("index out of range"); + + switch (subColIndex) + { + case 0: + { + char condType = conditions[subRowIndex].mSelectRule[1]; + switch (condType) + { + case '1': return 1; // Function + case '2': return 2; // Global + case '3': return 3; // Local + case '4': return 4; // Journal + case '5': return 5; // Item + case '6': return 6; // Dead + case '7': return 7; // Not ID + case '8': return 8; // Not Factio + case '9': return 9; // Not Class + case 'A': return 10; // Not Race + case 'B': return 11; // Not Cell + case 'C': return 12; // Not Local + default: return QVariant(); // TODO: log an error? + } + } + case 1: + { + if (conditions[subRowIndex].mSelectRule[1] == '1') + { + // throws an exception if the encoding is not found + return sEncToInfoFunc.at(conditions[subRowIndex].mSelectRule.substr(2, 2)).c_str(); + } + else + return QString(conditions[subRowIndex].mSelectRule.substr(5).c_str()); + } + case 2: + { + char compType = conditions[subRowIndex].mSelectRule[4]; + switch (compType) + { + case '0': return 3; // = + case '1': return 0; // != + case '2': return 4; // > + case '3': return 5; // >= + case '4': return 1; // < + case '5': return 2; // <= + default: return QVariant(); // TODO: log an error? + } + } + case 3: + { + switch (conditions[subRowIndex].mValue.getType()) + { + case ESM::VT_String: + { + return QString::fromUtf8 (conditions[subRowIndex].mValue.getString().c_str()); + } + case ESM::VT_Int: + case ESM::VT_Short: + case ESM::VT_Long: + { + return conditions[subRowIndex].mValue.getInteger(); + } + case ESM::VT_Float: + { + return conditions[subRowIndex].mValue.getFloat(); + } + default: return QVariant(); + } + } + default: throw std::runtime_error("Info condition subcolumn index out of range"); + } + } + + static const std::map sInfoFuncToEnc = + { + { "Alarm", "69" }, // AI + { "Alarmed", "49" }, + { "Attacked", "62" }, + { "Choice", "50" }, + { "Creature Target", "65" }, + { "Detected", "48" }, + { "Faction Rank Difference", "47" }, + { "Fight", "67" }, // AI + { "Flee", "70" }, // AI + { "Friend Hit", "66" }, + { "Health Percent", "04" }, + { "Hello", "68" }, // AI + { "Level", "61" }, + { "PC Acrobatics", "31" }, + { "PC Agility", "53" }, // attrib + { "PC Alchemy", "27" }, + { "PC Alteration", "22" }, + { "PC Armoror", "12" }, + { "PC Athletics", "19" }, + { "PC Axe", "17" }, + { "PC Blight Disease", "41" }, + { "PC Block", "11" }, + { "PC Blunt Weapon", "15" }, + { "PC Clothing Modifier", "42" }, + { "PC Common Disease", "40" }, + { "PC Conjuration", "24" }, + { "PC Corpus", "58" }, + { "PC Crime Level", "43" }, + { "PC Destruction", "21" }, + { "PC Enchant", "20" }, + { "PC Endurance", "55" }, // attrib + { "PC Expelled", "39" }, + { "PC Fatigue", "09" }, // dynamic stat + { "PC Hand To Hand", "37" }, + { "PC Health", "64" }, // dynamic stat + { "PC Health Percent", "07" }, + { "PC Heavy Armor", "14" }, + { "PC Illusion", "23" }, + { "PC Intelligence", "51" }, // attrib + { "PC Level", "06" }, + { "PC Light Armor", "32" }, + { "PC Long Blade", "16" }, + { "PC Luck", "57" }, // attrib + { "PC Magicka", "08" }, // dynamic stat + { "PC Marksman", "34" }, + { "PC Medium Armor", "13" }, + { "PC Merchantile", "35" }, + { "PC Mysticism", "25" }, + { "PC Personality", "56" }, // attrib + { "PC Reputation", "05" }, + { "PC Restoration", "26" }, + { "PC Security", "29" }, + { "PC Sex", "38" }, + { "PC Short Blade", "33" }, + { "PC Sneak", "30" }, + { "PC Spear", "18" }, + { "PC Speechcraft", "36" }, + { "PC Speed", "54" }, // attrib + { "PC Strength", "10" }, // attrib + { "PC Unarmored", "28" }, + { "PC Vampire", "60" }, + { "PC Werewolf Kills", "73" }, + { "PC Willpower", "52" }, // attrib + { "Rank Requirement", "02" }, + { "Rank High", "01" }, + { "Rank Low", "00" }, + { "Reputation", "03" }, + { "Same Faction", "46" }, + { "Same Race", "45" }, + { "Same Sex", "44" }, + { "Should Attack", "71" }, + { "Talked To PC", "63" }, + { "Weather", "59" }, + { "Werewolf", "72" } + }; + + void InfoConditionAdapter::setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const + { + Info info = record.get(); + + std::vector& conditions = info.mSelects; + + if (subRowIndex < 0 || subRowIndex >= static_cast (conditions.size())) + throw std::runtime_error ("index out of range"); + + switch (subColIndex) + { + case 0: + { + // See sInfoCondFunc in columns.cpp for the enum values + switch (value.toInt()) + { + // FIXME: when these change the values of the other columns need to change + // correspondingly (and automatically) + case 1: conditions[subRowIndex].mSelectRule[1] = '1'; break; // Function + case 2: conditions[subRowIndex].mSelectRule[1] = '2'; break; // Global + case 3: conditions[subRowIndex].mSelectRule[1] = '3'; break; // Local + case 4: conditions[subRowIndex].mSelectRule[1] = '4'; break; // Journal + case 5: conditions[subRowIndex].mSelectRule[1] = '5'; break; // Item + case 6: conditions[subRowIndex].mSelectRule[1] = '6'; break; // Dead + case 7: conditions[subRowIndex].mSelectRule[1] = '7'; break; // Not ID + case 8: conditions[subRowIndex].mSelectRule[1] = '8'; break; // Not Faction + case 9: conditions[subRowIndex].mSelectRule[1] = '9'; break; // Not Class + case 10: conditions[subRowIndex].mSelectRule[1] = 'A'; break; // Not Race + case 11: conditions[subRowIndex].mSelectRule[1] = 'B'; break; // Not Cell + case 12: conditions[subRowIndex].mSelectRule[1] = 'C'; break; // Not Local + default: return; // return without saving + } + break; + } + case 1: + { + if (conditions[subRowIndex].mSelectRule[1] == '1') + { + // throws an exception if the function is not found + const std::map::const_iterator it = sInfoFuncToEnc.find( + value.toString().toUtf8().constData()); + if (it != sInfoFuncToEnc.end()) + { + std::string rule = conditions[subRowIndex].mSelectRule.substr(0, 2); + rule.append(it->second); + rule.append(std::string(1, conditions[subRowIndex].mSelectRule[4])); + conditions[subRowIndex].mSelectRule = rule.append(value.toString().toUtf8().constData()); + } + else + return; // return without saving; TODO: maybe log an error here + } + else + { + // FIXME: validate the string values before saving, based on the current function + std::string rule = conditions[subRowIndex].mSelectRule.substr(0, 5); + conditions[subRowIndex].mSelectRule = rule.append(value.toString().toUtf8().constData()); + } + break; + } + case 2: + { + // See sInfoCondComp in columns.cpp for the enum values + switch (value.toInt()) + { + case 0: conditions[subRowIndex].mSelectRule[4] = '1'; break; // != + case 1: conditions[subRowIndex].mSelectRule[4] = '4'; break; // < + case 2: conditions[subRowIndex].mSelectRule[4] = '5'; break; // <= + case 3: conditions[subRowIndex].mSelectRule[4] = '0'; break; // = + case 4: conditions[subRowIndex].mSelectRule[4] = '2'; break; // > + case 5: conditions[subRowIndex].mSelectRule[4] = '3'; break; // >= + default: return; // return without saving + } + break; + } + case 3: + { + switch (conditions[subRowIndex].mValue.getType()) + { + case ESM::VT_String: + { + conditions[subRowIndex].mValue.setString (value.toString().toUtf8().constData()); + break; + } + case ESM::VT_Int: + case ESM::VT_Short: + case ESM::VT_Long: + { + conditions[subRowIndex].mValue.setInteger (value.toInt()); + break; + } + case ESM::VT_Float: + { + conditions[subRowIndex].mValue.setFloat (value.toFloat()); + break; + } + default: break; + } + } + default: throw std::runtime_error("Info condition subcolumn index out of range"); + } + + record.setModified (info); + } + + int InfoConditionAdapter::getColumnsCount(const Record& record) const + { + return 4; + } + + int InfoConditionAdapter::getRowsCount(const Record& record) const + { + return static_cast(record.get().mSelects.size()); + } } diff --git a/apps/opencs/model/world/nestedcoladapterimp.hpp b/apps/opencs/model/world/nestedcoladapterimp.hpp index 96dcd943de..ea2037eb82 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.hpp +++ b/apps/opencs/model/world/nestedcoladapterimp.hpp @@ -412,6 +412,31 @@ namespace CSMWorld virtual int getRowsCount(const Record& record) const; }; + + class InfoConditionAdapter : public NestedColumnAdapter + { + public: + InfoConditionAdapter (); + + virtual void addRow(Record& record, int position) const; + + virtual void removeRow(Record& record, int rowToRemove) const; + + virtual void setTable(Record& record, + const NestedTableWrapperBase& nestedTable) const; + + virtual NestedTableWrapperBase* table(const Record& record) const; + + virtual QVariant getData(const Record& record, + int subRowIndex, int subColIndex) const; + + virtual void setData(Record& record, + const QVariant& value, int subRowIndex, int subColIndex) const; + + virtual int getColumnsCount(const Record& record) const; + + virtual int getRowsCount(const Record& record) const; + }; } #endif // CSM_WOLRD_NESTEDCOLADAPTERIMP_H diff --git a/apps/opencs/view/doc/viewmanager.cpp b/apps/opencs/view/doc/viewmanager.cpp index 5908c67a19..6362f96590 100644 --- a/apps/opencs/view/doc/viewmanager.cpp +++ b/apps/opencs/view/doc/viewmanager.cpp @@ -90,7 +90,9 @@ CSVDoc::ViewManager::ViewManager (CSMDoc::DocumentManager& documentManager) { CSMWorld::ColumnBase::Display_EffectId, CSMWorld::Columns::ColumnId_EffectId, false }, { CSMWorld::ColumnBase::Display_PartRefType, CSMWorld::Columns::ColumnId_PartRefType, false }, { CSMWorld::ColumnBase::Display_AiPackageType, CSMWorld::Columns::ColumnId_AiPackageType, false }, - { CSMWorld::ColumnBase::Display_YesNo, CSMWorld::Columns::ColumnId_AiWanderRepeat, false } + { CSMWorld::ColumnBase::Display_YesNo, CSMWorld::Columns::ColumnId_AiWanderRepeat, false }, + { CSMWorld::ColumnBase::Display_InfoCondFunc, CSMWorld::Columns::ColumnId_InfoCondFunc, false }, + { CSMWorld::ColumnBase::Display_InfoCondComp, CSMWorld::Columns::ColumnId_InfoCondComp, false } }; for (std::size_t i=0; i Date: Sun, 10 May 2015 05:55:50 +1000 Subject: [PATCH 2/7] For compiling with osx - try using a different syntax for initializing the static maps. --- .../model/world/nestedcoladapterimp.cpp | 296 +++++++++--------- 1 file changed, 148 insertions(+), 148 deletions(-) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 9cd1a0a3b6..debb7ca2f6 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -592,80 +592,80 @@ namespace CSMWorld // from ESM::Attribute, ESM::Skill and MWMechanics::CreatureStats (for AI) static const std::map sEncToInfoFunc = { - { "00", "Rank Low" }, - { "01", "Rank High" }, - { "02", "Rank Requirement" }, - { "03", "Reputation" }, - { "04", "Health Percent" }, - { "05", "PC Reputation" }, - { "06", "PC Level" }, - { "07", "PC Health Percent" }, - { "08", "PC Magicka" }, // dynamic stat - { "09", "PC Fatigue" }, // dynamic stat - { "10", "PC Strength" }, // attrib - { "11", "PC Block" }, - { "12", "PC Armoror" }, - { "13", "PC Medium Armor" }, - { "14", "PC Heavy Armor" }, - { "15", "PC Blunt Weapon" }, - { "16", "PC Long Blade" }, - { "17", "PC Axe" }, - { "18", "PC Spear" }, - { "19", "PC Athletics" }, - { "20", "PC Enchant" }, - { "21", "PC Destruction" }, - { "22", "PC Alteration" }, - { "23", "PC Illusion" }, - { "24", "PC Conjuration" }, - { "25", "PC Mysticism" }, - { "26", "PC Restoration" }, - { "27", "PC Alchemy" }, - { "28", "PC Unarmored" }, - { "29", "PC Security" }, - { "30", "PC Sneak" }, - { "31", "PC Acrobatics" }, - { "32", "PC Light Armor" }, - { "33", "PC Short Blade" }, - { "34", "PC Marksman" }, - { "35", "PC Merchantile" }, - { "36", "PC Speechcraft" }, - { "37", "PC Hand To Hand" }, - { "38", "PC Sex" }, - { "39", "PC Expelled" }, - { "40", "PC Common Disease" }, - { "41", "PC Blight Disease" }, - { "42", "PC Clothing Modifier" }, - { "43", "PC Crime Level" }, - { "44", "Same Sex" }, - { "45", "Same Race" }, - { "46", "Same Faction" }, - { "47", "Faction Rank Difference" }, - { "48", "Detected" }, - { "49", "Alarmed" }, - { "50", "Choice" }, - { "51", "PC Intelligence" }, // attrib - { "52", "PC Willpower" }, // attrib - { "53", "PC Agility" }, // attrib - { "54", "PC Speed" }, // attrib - { "55", "PC Endurance" }, // attrib - { "56", "PC Personality" }, // attrib - { "57", "PC Luck" }, // attrib - { "58", "PC Corpus" }, - { "59", "Weather" }, - { "60", "PC Vampire" }, - { "61", "Level" }, - { "62", "Attacked" }, - { "63", "Talked To PC" }, - { "64", "PC Health" }, // dynamic stat - { "65", "Creature Target" }, - { "66", "Friend Hit" }, - { "67", "Fight" }, // AI - { "68", "Hello" }, // AI - { "69", "Alarm" }, // AI - { "70", "Flee" }, // AI - { "71", "Should Attack" }, - { "72", "Werewolf" }, - { "73", "PC Werewolf Kills" } + std::make_pair( "00", "Rank Low" ), + std::make_pair( "01", "Rank High" ), + std::make_pair( "02", "Rank Requirement" ), + std::make_pair( "03", "Reputation" ), + std::make_pair( "04", "Health Percent" ), + std::make_pair( "05", "PC Reputation" ), + std::make_pair( "06", "PC Level" ), + std::make_pair( "07", "PC Health Percent" ), + std::make_pair( "08", "PC Magicka" ), // dynamic stat + std::make_pair( "09", "PC Fatigue" ), // dynamic stat + std::make_pair( "10", "PC Strength" ), // attrib + std::make_pair( "11", "PC Block" ), + std::make_pair( "12", "PC Armoror" ), + std::make_pair( "13", "PC Medium Armor" ), + std::make_pair( "14", "PC Heavy Armor" ), + std::make_pair( "15", "PC Blunt Weapon" ), + std::make_pair( "16", "PC Long Blade" ), + std::make_pair( "17", "PC Axe" ), + std::make_pair( "18", "PC Spear" ), + std::make_pair( "19", "PC Athletics" ), + std::make_pair( "20", "PC Enchant" ), + std::make_pair( "21", "PC Destruction" ), + std::make_pair( "22", "PC Alteration" ), + std::make_pair( "23", "PC Illusion" ), + std::make_pair( "24", "PC Conjuration" ), + std::make_pair( "25", "PC Mysticism" ), + std::make_pair( "26", "PC Restoration" ), + std::make_pair( "27", "PC Alchemy" ), + std::make_pair( "28", "PC Unarmored" ), + std::make_pair( "29", "PC Security" ), + std::make_pair( "30", "PC Sneak" ), + std::make_pair( "31", "PC Acrobatics" ), + std::make_pair( "32", "PC Light Armor" ), + std::make_pair( "33", "PC Short Blade" ), + std::make_pair( "34", "PC Marksman" ), + std::make_pair( "35", "PC Merchantile" ), + std::make_pair( "36", "PC Speechcraft" ), + std::make_pair( "37", "PC Hand To Hand" ), + std::make_pair( "38", "PC Sex" ), + std::make_pair( "39", "PC Expelled" ), + std::make_pair( "40", "PC Common Disease" ), + std::make_pair( "41", "PC Blight Disease" ), + std::make_pair( "42", "PC Clothing Modifier" ), + std::make_pair( "43", "PC Crime Level" ), + std::make_pair( "44", "Same Sex" ), + std::make_pair( "45", "Same Race" ), + std::make_pair( "46", "Same Faction" ), + std::make_pair( "47", "Faction Rank Difference" ), + std::make_pair( "48", "Detected" ), + std::make_pair( "49", "Alarmed" ), + std::make_pair( "50", "Choice" ), + std::make_pair( "51", "PC Intelligence" ), // attrib + std::make_pair( "52", "PC Willpower" ), // attrib + std::make_pair( "53", "PC Agility" ), // attrib + std::make_pair( "54", "PC Speed" ), // attrib + std::make_pair( "55", "PC Endurance" ), // attrib + std::make_pair( "56", "PC Personality" ), // attrib + std::make_pair( "57", "PC Luck" ), // attrib + std::make_pair( "58", "PC Corpus" ), + std::make_pair( "59", "Weather" ), + std::make_pair( "60", "PC Vampire" ), + std::make_pair( "61", "Level" ), + std::make_pair( "62", "Attacked" ), + std::make_pair( "63", "Talked To PC" ), + std::make_pair( "64", "PC Health" ), // dynamic stat + std::make_pair( "65", "Creature Target" ), + std::make_pair( "66", "Friend Hit" ), + std::make_pair( "67", "Fight" ), // AI + std::make_pair( "68", "Hello" ), // AI + std::make_pair( "69", "Alarm" ), // AI + std::make_pair( "70", "Flee" ), // AI + std::make_pair( "71", "Should Attack" ), + std::make_pair( "72", "Werewolf" ), + std::make_pair( "73", "PC Werewolf Kills" ) }; QVariant InfoConditionAdapter::getData(const Record& record, @@ -751,80 +751,80 @@ namespace CSMWorld static const std::map sInfoFuncToEnc = { - { "Alarm", "69" }, // AI - { "Alarmed", "49" }, - { "Attacked", "62" }, - { "Choice", "50" }, - { "Creature Target", "65" }, - { "Detected", "48" }, - { "Faction Rank Difference", "47" }, - { "Fight", "67" }, // AI - { "Flee", "70" }, // AI - { "Friend Hit", "66" }, - { "Health Percent", "04" }, - { "Hello", "68" }, // AI - { "Level", "61" }, - { "PC Acrobatics", "31" }, - { "PC Agility", "53" }, // attrib - { "PC Alchemy", "27" }, - { "PC Alteration", "22" }, - { "PC Armoror", "12" }, - { "PC Athletics", "19" }, - { "PC Axe", "17" }, - { "PC Blight Disease", "41" }, - { "PC Block", "11" }, - { "PC Blunt Weapon", "15" }, - { "PC Clothing Modifier", "42" }, - { "PC Common Disease", "40" }, - { "PC Conjuration", "24" }, - { "PC Corpus", "58" }, - { "PC Crime Level", "43" }, - { "PC Destruction", "21" }, - { "PC Enchant", "20" }, - { "PC Endurance", "55" }, // attrib - { "PC Expelled", "39" }, - { "PC Fatigue", "09" }, // dynamic stat - { "PC Hand To Hand", "37" }, - { "PC Health", "64" }, // dynamic stat - { "PC Health Percent", "07" }, - { "PC Heavy Armor", "14" }, - { "PC Illusion", "23" }, - { "PC Intelligence", "51" }, // attrib - { "PC Level", "06" }, - { "PC Light Armor", "32" }, - { "PC Long Blade", "16" }, - { "PC Luck", "57" }, // attrib - { "PC Magicka", "08" }, // dynamic stat - { "PC Marksman", "34" }, - { "PC Medium Armor", "13" }, - { "PC Merchantile", "35" }, - { "PC Mysticism", "25" }, - { "PC Personality", "56" }, // attrib - { "PC Reputation", "05" }, - { "PC Restoration", "26" }, - { "PC Security", "29" }, - { "PC Sex", "38" }, - { "PC Short Blade", "33" }, - { "PC Sneak", "30" }, - { "PC Spear", "18" }, - { "PC Speechcraft", "36" }, - { "PC Speed", "54" }, // attrib - { "PC Strength", "10" }, // attrib - { "PC Unarmored", "28" }, - { "PC Vampire", "60" }, - { "PC Werewolf Kills", "73" }, - { "PC Willpower", "52" }, // attrib - { "Rank Requirement", "02" }, - { "Rank High", "01" }, - { "Rank Low", "00" }, - { "Reputation", "03" }, - { "Same Faction", "46" }, - { "Same Race", "45" }, - { "Same Sex", "44" }, - { "Should Attack", "71" }, - { "Talked To PC", "63" }, - { "Weather", "59" }, - { "Werewolf", "72" } + std::make_pair( "Alarm", "69" ), // AI + std::make_pair( "Alarmed", "49" ), + std::make_pair( "Attacked", "62" ), + std::make_pair( "Choice", "50" ), + std::make_pair( "Creature Target", "65" ), + std::make_pair( "Detected", "48" ), + std::make_pair( "Faction Rank Difference", "47" ), + std::make_pair( "Fight", "67" ), // AI + std::make_pair( "Flee", "70" ), // AI + std::make_pair( "Friend Hit", "66" ), + std::make_pair( "Health Percent", "04" ), + std::make_pair( "Hello", "68" ), // AI + std::make_pair( "Level", "61" ), + std::make_pair( "PC Acrobatics", "31" ), + std::make_pair( "PC Agility", "53" ), // attrib + std::make_pair( "PC Alchemy", "27" ), + std::make_pair( "PC Alteration", "22" ), + std::make_pair( "PC Armoror", "12" ), + std::make_pair( "PC Athletics", "19" ), + std::make_pair( "PC Axe", "17" ), + std::make_pair( "PC Blight Disease", "41" ), + std::make_pair( "PC Block", "11" ), + std::make_pair( "PC Blunt Weapon", "15" ), + std::make_pair( "PC Clothing Modifier", "42" ), + std::make_pair( "PC Common Disease", "40" ), + std::make_pair( "PC Conjuration", "24" ), + std::make_pair( "PC Corpus", "58" ), + std::make_pair( "PC Crime Level", "43" ), + std::make_pair( "PC Destruction", "21" ), + std::make_pair( "PC Enchant", "20" ), + std::make_pair( "PC Endurance", "55" ), // attrib + std::make_pair( "PC Expelled", "39" ), + std::make_pair( "PC Fatigue", "09" ), // dynamic stat + std::make_pair( "PC Hand To Hand", "37" ), + std::make_pair( "PC Health", "64" ), // dynamic stat + std::make_pair( "PC Health Percent", "07" ), + std::make_pair( "PC Heavy Armor", "14" ), + std::make_pair( "PC Illusion", "23" ), + std::make_pair( "PC Intelligence", "51" ), // attrib + std::make_pair( "PC Level", "06" ), + std::make_pair( "PC Light Armor", "32" ), + std::make_pair( "PC Long Blade", "16" ), + std::make_pair( "PC Luck", "57" ), // attrib + std::make_pair( "PC Magicka", "08" ), // dynamic stat + std::make_pair( "PC Marksman", "34" ), + std::make_pair( "PC Medium Armor", "13" ), + std::make_pair( "PC Merchantile", "35" ), + std::make_pair( "PC Mysticism", "25" ), + std::make_pair( "PC Personality", "56" ), // attrib + std::make_pair( "PC Reputation", "05" ), + std::make_pair( "PC Restoration", "26" ), + std::make_pair( "PC Security", "29" ), + std::make_pair( "PC Sex", "38" ), + std::make_pair( "PC Short Blade", "33" ), + std::make_pair( "PC Sneak", "30" ), + std::make_pair( "PC Spear", "18" ), + std::make_pair( "PC Speechcraft", "36" ), + std::make_pair( "PC Speed", "54" ), // attrib + std::make_pair( "PC Strength", "10" ), // attrib + std::make_pair( "PC Unarmored", "28" ), + std::make_pair( "PC Vampire", "60" ), + std::make_pair( "PC Werewolf Kills", "73" ), + std::make_pair( "PC Willpower", "52" ), // attrib + std::make_pair( "Rank Requirement", "02" ), + std::make_pair( "Rank High", "01" ), + std::make_pair( "Rank Low", "00" ), + std::make_pair( "Reputation", "03" ), + std::make_pair( "Same Faction", "46" ), + std::make_pair( "Same Race", "45" ), + std::make_pair( "Same Sex", "44" ), + std::make_pair( "Should Attack", "71" ), + std::make_pair( "Talked To PC", "63" ), + std::make_pair( "Weather", "59" ), + std::make_pair( "Werewolf", "72" ) }; void InfoConditionAdapter::setData(Record& record, From d6ecc64168bf164d7157abe4b8deaf3336fd3d8f Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 10 May 2015 06:17:57 +1000 Subject: [PATCH 3/7] Aggregate types can't be static - osx compiler appears to be more strict. --- .../model/world/nestedcoladapterimp.cpp | 304 +++++++++--------- 1 file changed, 152 insertions(+), 152 deletions(-) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index debb7ca2f6..f1088829ed 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -590,82 +590,82 @@ namespace CSMWorld // See the mappings in MWDialogue::SelectWrapper::getArgument // from ESM::Attribute, ESM::Skill and MWMechanics::CreatureStats (for AI) - static const std::map sEncToInfoFunc = - { - std::make_pair( "00", "Rank Low" ), - std::make_pair( "01", "Rank High" ), - std::make_pair( "02", "Rank Requirement" ), - std::make_pair( "03", "Reputation" ), - std::make_pair( "04", "Health Percent" ), - std::make_pair( "05", "PC Reputation" ), - std::make_pair( "06", "PC Level" ), - std::make_pair( "07", "PC Health Percent" ), - std::make_pair( "08", "PC Magicka" ), // dynamic stat - std::make_pair( "09", "PC Fatigue" ), // dynamic stat - std::make_pair( "10", "PC Strength" ), // attrib - std::make_pair( "11", "PC Block" ), - std::make_pair( "12", "PC Armoror" ), - std::make_pair( "13", "PC Medium Armor" ), - std::make_pair( "14", "PC Heavy Armor" ), - std::make_pair( "15", "PC Blunt Weapon" ), - std::make_pair( "16", "PC Long Blade" ), - std::make_pair( "17", "PC Axe" ), - std::make_pair( "18", "PC Spear" ), - std::make_pair( "19", "PC Athletics" ), - std::make_pair( "20", "PC Enchant" ), - std::make_pair( "21", "PC Destruction" ), - std::make_pair( "22", "PC Alteration" ), - std::make_pair( "23", "PC Illusion" ), - std::make_pair( "24", "PC Conjuration" ), - std::make_pair( "25", "PC Mysticism" ), - std::make_pair( "26", "PC Restoration" ), - std::make_pair( "27", "PC Alchemy" ), - std::make_pair( "28", "PC Unarmored" ), - std::make_pair( "29", "PC Security" ), - std::make_pair( "30", "PC Sneak" ), - std::make_pair( "31", "PC Acrobatics" ), - std::make_pair( "32", "PC Light Armor" ), - std::make_pair( "33", "PC Short Blade" ), - std::make_pair( "34", "PC Marksman" ), - std::make_pair( "35", "PC Merchantile" ), - std::make_pair( "36", "PC Speechcraft" ), - std::make_pair( "37", "PC Hand To Hand" ), - std::make_pair( "38", "PC Sex" ), - std::make_pair( "39", "PC Expelled" ), - std::make_pair( "40", "PC Common Disease" ), - std::make_pair( "41", "PC Blight Disease" ), - std::make_pair( "42", "PC Clothing Modifier" ), - std::make_pair( "43", "PC Crime Level" ), - std::make_pair( "44", "Same Sex" ), - std::make_pair( "45", "Same Race" ), - std::make_pair( "46", "Same Faction" ), - std::make_pair( "47", "Faction Rank Difference" ), - std::make_pair( "48", "Detected" ), - std::make_pair( "49", "Alarmed" ), - std::make_pair( "50", "Choice" ), - std::make_pair( "51", "PC Intelligence" ), // attrib - std::make_pair( "52", "PC Willpower" ), // attrib - std::make_pair( "53", "PC Agility" ), // attrib - std::make_pair( "54", "PC Speed" ), // attrib - std::make_pair( "55", "PC Endurance" ), // attrib - std::make_pair( "56", "PC Personality" ), // attrib - std::make_pair( "57", "PC Luck" ), // attrib - std::make_pair( "58", "PC Corpus" ), - std::make_pair( "59", "Weather" ), - std::make_pair( "60", "PC Vampire" ), - std::make_pair( "61", "Level" ), - std::make_pair( "62", "Attacked" ), - std::make_pair( "63", "Talked To PC" ), - std::make_pair( "64", "PC Health" ), // dynamic stat - std::make_pair( "65", "Creature Target" ), - std::make_pair( "66", "Friend Hit" ), - std::make_pair( "67", "Fight" ), // AI - std::make_pair( "68", "Hello" ), // AI - std::make_pair( "69", "Alarm" ), // AI - std::make_pair( "70", "Flee" ), // AI - std::make_pair( "71", "Should Attack" ), - std::make_pair( "72", "Werewolf" ), - std::make_pair( "73", "PC Werewolf Kills" ) + const std::map sEncToInfoFunc = + { + { "00", "Rank Low" }, + { "01", "Rank High" }, + { "02", "Rank Requirement" }, + { "03", "Reputation" }, + { "04", "Health Percent" }, + { "05", "PC Reputation" }, + { "06", "PC Level" }, + { "07", "PC Health Percent" }, + { "08", "PC Magicka" }, // dynamic stat + { "09", "PC Fatigue" }, // dynamic stat + { "10", "PC Strength" }, // attrib + { "11", "PC Block" }, + { "12", "PC Armoror" }, + { "13", "PC Medium Armor" }, + { "14", "PC Heavy Armor" }, + { "15", "PC Blunt Weapon" }, + { "16", "PC Long Blade" }, + { "17", "PC Axe" }, + { "18", "PC Spear" }, + { "19", "PC Athletics" }, + { "20", "PC Enchant" }, + { "21", "PC Destruction" }, + { "22", "PC Alteration" }, + { "23", "PC Illusion" }, + { "24", "PC Conjuration" }, + { "25", "PC Mysticism" }, + { "26", "PC Restoration" }, + { "27", "PC Alchemy" }, + { "28", "PC Unarmored" }, + { "29", "PC Security" }, + { "30", "PC Sneak" }, + { "31", "PC Acrobatics" }, + { "32", "PC Light Armor" }, + { "33", "PC Short Blade" }, + { "34", "PC Marksman" }, + { "35", "PC Merchantile" }, + { "36", "PC Speechcraft" }, + { "37", "PC Hand To Hand" }, + { "38", "PC Sex" }, + { "39", "PC Expelled" }, + { "40", "PC Common Disease" }, + { "41", "PC Blight Disease" }, + { "42", "PC Clothing Modifier" }, + { "43", "PC Crime Level" }, + { "44", "Same Sex" }, + { "45", "Same Race" }, + { "46", "Same Faction" }, + { "47", "Faction Rank Difference" }, + { "48", "Detected" }, + { "49", "Alarmed" }, + { "50", "Choice" }, + { "51", "PC Intelligence" }, // attrib + { "52", "PC Willpower" }, // attrib + { "53", "PC Agility" }, // attrib + { "54", "PC Speed" }, // attrib + { "55", "PC Endurance" }, // attrib + { "56", "PC Personality" }, // attrib + { "57", "PC Luck" }, // attrib + { "58", "PC Corpus" }, + { "59", "Weather" }, + { "60", "PC Vampire" }, + { "61", "Level" }, + { "62", "Attacked" }, + { "63", "Talked To PC" }, + { "64", "PC Health" }, // dynamic stat + { "65", "Creature Target" }, + { "66", "Friend Hit" }, + { "67", "Fight" }, // AI + { "68", "Hello" }, // AI + { "69", "Alarm" }, // AI + { "70", "Flee" }, // AI + { "71", "Should Attack" }, + { "72", "Werewolf" }, + { "73", "PC Werewolf Kills" } }; QVariant InfoConditionAdapter::getData(const Record& record, @@ -749,82 +749,82 @@ namespace CSMWorld } } - static const std::map sInfoFuncToEnc = - { - std::make_pair( "Alarm", "69" ), // AI - std::make_pair( "Alarmed", "49" ), - std::make_pair( "Attacked", "62" ), - std::make_pair( "Choice", "50" ), - std::make_pair( "Creature Target", "65" ), - std::make_pair( "Detected", "48" ), - std::make_pair( "Faction Rank Difference", "47" ), - std::make_pair( "Fight", "67" ), // AI - std::make_pair( "Flee", "70" ), // AI - std::make_pair( "Friend Hit", "66" ), - std::make_pair( "Health Percent", "04" ), - std::make_pair( "Hello", "68" ), // AI - std::make_pair( "Level", "61" ), - std::make_pair( "PC Acrobatics", "31" ), - std::make_pair( "PC Agility", "53" ), // attrib - std::make_pair( "PC Alchemy", "27" ), - std::make_pair( "PC Alteration", "22" ), - std::make_pair( "PC Armoror", "12" ), - std::make_pair( "PC Athletics", "19" ), - std::make_pair( "PC Axe", "17" ), - std::make_pair( "PC Blight Disease", "41" ), - std::make_pair( "PC Block", "11" ), - std::make_pair( "PC Blunt Weapon", "15" ), - std::make_pair( "PC Clothing Modifier", "42" ), - std::make_pair( "PC Common Disease", "40" ), - std::make_pair( "PC Conjuration", "24" ), - std::make_pair( "PC Corpus", "58" ), - std::make_pair( "PC Crime Level", "43" ), - std::make_pair( "PC Destruction", "21" ), - std::make_pair( "PC Enchant", "20" ), - std::make_pair( "PC Endurance", "55" ), // attrib - std::make_pair( "PC Expelled", "39" ), - std::make_pair( "PC Fatigue", "09" ), // dynamic stat - std::make_pair( "PC Hand To Hand", "37" ), - std::make_pair( "PC Health", "64" ), // dynamic stat - std::make_pair( "PC Health Percent", "07" ), - std::make_pair( "PC Heavy Armor", "14" ), - std::make_pair( "PC Illusion", "23" ), - std::make_pair( "PC Intelligence", "51" ), // attrib - std::make_pair( "PC Level", "06" ), - std::make_pair( "PC Light Armor", "32" ), - std::make_pair( "PC Long Blade", "16" ), - std::make_pair( "PC Luck", "57" ), // attrib - std::make_pair( "PC Magicka", "08" ), // dynamic stat - std::make_pair( "PC Marksman", "34" ), - std::make_pair( "PC Medium Armor", "13" ), - std::make_pair( "PC Merchantile", "35" ), - std::make_pair( "PC Mysticism", "25" ), - std::make_pair( "PC Personality", "56" ), // attrib - std::make_pair( "PC Reputation", "05" ), - std::make_pair( "PC Restoration", "26" ), - std::make_pair( "PC Security", "29" ), - std::make_pair( "PC Sex", "38" ), - std::make_pair( "PC Short Blade", "33" ), - std::make_pair( "PC Sneak", "30" ), - std::make_pair( "PC Spear", "18" ), - std::make_pair( "PC Speechcraft", "36" ), - std::make_pair( "PC Speed", "54" ), // attrib - std::make_pair( "PC Strength", "10" ), // attrib - std::make_pair( "PC Unarmored", "28" ), - std::make_pair( "PC Vampire", "60" ), - std::make_pair( "PC Werewolf Kills", "73" ), - std::make_pair( "PC Willpower", "52" ), // attrib - std::make_pair( "Rank Requirement", "02" ), - std::make_pair( "Rank High", "01" ), - std::make_pair( "Rank Low", "00" ), - std::make_pair( "Reputation", "03" ), - std::make_pair( "Same Faction", "46" ), - std::make_pair( "Same Race", "45" ), - std::make_pair( "Same Sex", "44" ), - std::make_pair( "Should Attack", "71" ), - std::make_pair( "Talked To PC", "63" ), - std::make_pair( "Weather", "59" ), - std::make_pair( "Werewolf", "72" ) + const std::map sInfoFuncToEnc = + { + { "Alarm", "69" }, // AI + { "Alarmed", "49" }, + { "Attacked", "62" }, + { "Choice", "50" }, + { "Creature Target", "65" }, + { "Detected", "48" }, + { "Faction Rank Difference", "47" }, + { "Fight", "67" }, // AI + { "Flee", "70" }, // AI + { "Friend Hit", "66" }, + { "Health Percent", "04" }, + { "Hello", "68" }, // AI + { "Level", "61" }, + { "PC Acrobatics", "31" }, + { "PC Agility", "53" }, // attrib + { "PC Alchemy", "27" }, + { "PC Alteration", "22" }, + { "PC Armoror", "12" }, + { "PC Athletics", "19" }, + { "PC Axe", "17" }, + { "PC Blight Disease", "41" }, + { "PC Block", "11" }, + { "PC Blunt Weapon", "15" }, + { "PC Clothing Modifier", "42" }, + { "PC Common Disease", "40" }, + { "PC Conjuration", "24" }, + { "PC Corpus", "58" }, + { "PC Crime Level", "43" }, + { "PC Destruction", "21" }, + { "PC Enchant", "20" }, + { "PC Endurance", "55" }, // attrib + { "PC Expelled", "39" }, + { "PC Fatigue", "09" }, // dynamic stat + { "PC Hand To Hand", "37" }, + { "PC Health", "64" }, // dynamic stat + { "PC Health Percent", "07" }, + { "PC Heavy Armor", "14" }, + { "PC Illusion", "23" }, + { "PC Intelligence", "51" }, // attrib + { "PC Level", "06" }, + { "PC Light Armor", "32" }, + { "PC Long Blade", "16" }, + { "PC Luck", "57" }, // attrib + { "PC Magicka", "08" }, // dynamic stat + { "PC Marksman", "34" }, + { "PC Medium Armor", "13" }, + { "PC Merchantile", "35" }, + { "PC Mysticism", "25" }, + { "PC Personality", "56" }, // attrib + { "PC Reputation", "05" }, + { "PC Restoration", "26" }, + { "PC Security", "29" }, + { "PC Sex", "38" }, + { "PC Short Blade", "33" }, + { "PC Sneak", "30" }, + { "PC Spear", "18" }, + { "PC Speechcraft", "36" }, + { "PC Speed", "54" }, // attrib + { "PC Strength", "10" }, // attrib + { "PC Unarmored", "28" }, + { "PC Vampire", "60" }, + { "PC Werewolf Kills", "73" }, + { "PC Willpower", "52" }, // attrib + { "Rank Requirement", "02" }, + { "Rank High", "01" }, + { "Rank Low", "00" }, + { "Reputation", "03" }, + { "Same Faction", "46" }, + { "Same Race", "45" }, + { "Same Sex", "44" }, + { "Should Attack", "71" }, + { "Talked To PC", "63" }, + { "Weather", "59" }, + { "Werewolf", "72" } }; void InfoConditionAdapter::setData(Record& record, From 5fb269336f3d7e78588141a0d21bba15b55db76e Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 10 May 2015 07:02:08 +1000 Subject: [PATCH 4/7] Don't use initializer list --- .../model/world/nestedcoladapterimp.cpp | 316 +++++++++--------- 1 file changed, 161 insertions(+), 155 deletions(-) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index f1088829ed..8ee4af2f8a 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -590,83 +590,86 @@ namespace CSMWorld // See the mappings in MWDialogue::SelectWrapper::getArgument // from ESM::Attribute, ESM::Skill and MWMechanics::CreatureStats (for AI) - const std::map sEncToInfoFunc = - { - { "00", "Rank Low" }, - { "01", "Rank High" }, - { "02", "Rank Requirement" }, - { "03", "Reputation" }, - { "04", "Health Percent" }, - { "05", "PC Reputation" }, - { "06", "PC Level" }, - { "07", "PC Health Percent" }, - { "08", "PC Magicka" }, // dynamic stat - { "09", "PC Fatigue" }, // dynamic stat - { "10", "PC Strength" }, // attrib - { "11", "PC Block" }, - { "12", "PC Armoror" }, - { "13", "PC Medium Armor" }, - { "14", "PC Heavy Armor" }, - { "15", "PC Blunt Weapon" }, - { "16", "PC Long Blade" }, - { "17", "PC Axe" }, - { "18", "PC Spear" }, - { "19", "PC Athletics" }, - { "20", "PC Enchant" }, - { "21", "PC Destruction" }, - { "22", "PC Alteration" }, - { "23", "PC Illusion" }, - { "24", "PC Conjuration" }, - { "25", "PC Mysticism" }, - { "26", "PC Restoration" }, - { "27", "PC Alchemy" }, - { "28", "PC Unarmored" }, - { "29", "PC Security" }, - { "30", "PC Sneak" }, - { "31", "PC Acrobatics" }, - { "32", "PC Light Armor" }, - { "33", "PC Short Blade" }, - { "34", "PC Marksman" }, - { "35", "PC Merchantile" }, - { "36", "PC Speechcraft" }, - { "37", "PC Hand To Hand" }, - { "38", "PC Sex" }, - { "39", "PC Expelled" }, - { "40", "PC Common Disease" }, - { "41", "PC Blight Disease" }, - { "42", "PC Clothing Modifier" }, - { "43", "PC Crime Level" }, - { "44", "Same Sex" }, - { "45", "Same Race" }, - { "46", "Same Faction" }, - { "47", "Faction Rank Difference" }, - { "48", "Detected" }, - { "49", "Alarmed" }, - { "50", "Choice" }, - { "51", "PC Intelligence" }, // attrib - { "52", "PC Willpower" }, // attrib - { "53", "PC Agility" }, // attrib - { "54", "PC Speed" }, // attrib - { "55", "PC Endurance" }, // attrib - { "56", "PC Personality" }, // attrib - { "57", "PC Luck" }, // attrib - { "58", "PC Corpus" }, - { "59", "Weather" }, - { "60", "PC Vampire" }, - { "61", "Level" }, - { "62", "Attacked" }, - { "63", "Talked To PC" }, - { "64", "PC Health" }, // dynamic stat - { "65", "Creature Target" }, - { "66", "Friend Hit" }, - { "67", "Fight" }, // AI - { "68", "Hello" }, // AI - { "69", "Alarm" }, // AI - { "70", "Flee" }, // AI - { "71", "Should Attack" }, - { "72", "Werewolf" }, - { "73", "PC Werewolf Kills" } - }; + static std::map populateEncToInfoFunc() + { + std::map funcMap; + funcMap["00"] = "Rank Low"; + funcMap["01"] = "Rank High"; + funcMap["02"] = "Rank Requirement"; + funcMap["03"] = "Reputation"; + funcMap["04"] = "Health Percent"; + funcMap["05"] = "PC Reputation"; + funcMap["06"] = "PC Level"; + funcMap["07"] = "PC Health Percent"; + funcMap["08"] = "PC Magicka"; + funcMap["09"] = "PC Fatigue"; + funcMap["10"] = "PC Strength"; + funcMap["11"] = "PC Block"; + funcMap["12"] = "PC Armoror"; + funcMap["13"] = "PC Medium Armor"; + funcMap["14"] = "PC Heavy Armor"; + funcMap["15"] = "PC Blunt Weapon"; + funcMap["16"] = "PC Long Blade"; + funcMap["17"] = "PC Axe"; + funcMap["18"] = "PC Spear"; + funcMap["19"] = "PC Athletics"; + funcMap["20"] = "PC Enchant"; + funcMap["21"] = "PC Destruction"; + funcMap["22"] = "PC Alteration"; + funcMap["23"] = "PC Illusion"; + funcMap["24"] = "PC Conjuration"; + funcMap["25"] = "PC Mysticism"; + funcMap["26"] = "PC Restoration"; + funcMap["27"] = "PC Alchemy"; + funcMap["28"] = "PC Unarmored"; + funcMap["29"] = "PC Security"; + funcMap["30"] = "PC Sneak"; + funcMap["31"] = "PC Acrobatics"; + funcMap["32"] = "PC Light Armor"; + funcMap["33"] = "PC Short Blade"; + funcMap["34"] = "PC Marksman"; + funcMap["35"] = "PC Merchantile"; + funcMap["36"] = "PC Speechcraft"; + funcMap["37"] = "PC Hand To Hand"; + funcMap["38"] = "PC Sex"; + funcMap["39"] = "PC Expelled"; + funcMap["40"] = "PC Common Disease"; + funcMap["41"] = "PC Blight Disease"; + funcMap["42"] = "PC Clothing Modifier"; + funcMap["43"] = "PC Crime Level"; + funcMap["44"] = "Same Sex"; + funcMap["45"] = "Same Race"; + funcMap["46"] = "Same Faction"; + funcMap["47"] = "Faction Rank Difference"; + funcMap["48"] = "Detected"; + funcMap["49"] = "Alarmed"; + funcMap["50"] = "Choice"; + funcMap["51"] = "PC Intelligence"; + funcMap["52"] = "PC Willpower"; + funcMap["53"] = "PC Agility"; + funcMap["54"] = "PC Speed"; + funcMap["55"] = "PC Endurance"; + funcMap["56"] = "PC Personality"; + funcMap["57"] = "PC Luck"; + funcMap["58"] = "PC Corpus"; + funcMap["59"] = "Weather"; + funcMap["60"] = "PC Vampire"; + funcMap["61"] = "Level"; + funcMap["62"] = "Attacked"; + funcMap["63"] = "Talked To PC"; + funcMap["64"] = "PC Health"; + funcMap["65"] = "Creature Target"; + funcMap["66"] = "Friend Hit"; + funcMap["67"] = "Fight"; + funcMap["68"] = "Hello"; + funcMap["69"] = "Alarm"; + funcMap["70"] = "Flee"; + funcMap["71"] = "Should Attack"; + funcMap["72"] = "Werewolf"; + funcMap["73"] = "PC Werewolf Kills"; + return funcMap; + } + static const std::map sEncToInfoFunc = populateEncToInfoFunc(); QVariant InfoConditionAdapter::getData(const Record& record, int subRowIndex, int subColIndex) const @@ -749,83 +752,86 @@ namespace CSMWorld } } - const std::map sInfoFuncToEnc = - { - { "Alarm", "69" }, // AI - { "Alarmed", "49" }, - { "Attacked", "62" }, - { "Choice", "50" }, - { "Creature Target", "65" }, - { "Detected", "48" }, - { "Faction Rank Difference", "47" }, - { "Fight", "67" }, // AI - { "Flee", "70" }, // AI - { "Friend Hit", "66" }, - { "Health Percent", "04" }, - { "Hello", "68" }, // AI - { "Level", "61" }, - { "PC Acrobatics", "31" }, - { "PC Agility", "53" }, // attrib - { "PC Alchemy", "27" }, - { "PC Alteration", "22" }, - { "PC Armoror", "12" }, - { "PC Athletics", "19" }, - { "PC Axe", "17" }, - { "PC Blight Disease", "41" }, - { "PC Block", "11" }, - { "PC Blunt Weapon", "15" }, - { "PC Clothing Modifier", "42" }, - { "PC Common Disease", "40" }, - { "PC Conjuration", "24" }, - { "PC Corpus", "58" }, - { "PC Crime Level", "43" }, - { "PC Destruction", "21" }, - { "PC Enchant", "20" }, - { "PC Endurance", "55" }, // attrib - { "PC Expelled", "39" }, - { "PC Fatigue", "09" }, // dynamic stat - { "PC Hand To Hand", "37" }, - { "PC Health", "64" }, // dynamic stat - { "PC Health Percent", "07" }, - { "PC Heavy Armor", "14" }, - { "PC Illusion", "23" }, - { "PC Intelligence", "51" }, // attrib - { "PC Level", "06" }, - { "PC Light Armor", "32" }, - { "PC Long Blade", "16" }, - { "PC Luck", "57" }, // attrib - { "PC Magicka", "08" }, // dynamic stat - { "PC Marksman", "34" }, - { "PC Medium Armor", "13" }, - { "PC Merchantile", "35" }, - { "PC Mysticism", "25" }, - { "PC Personality", "56" }, // attrib - { "PC Reputation", "05" }, - { "PC Restoration", "26" }, - { "PC Security", "29" }, - { "PC Sex", "38" }, - { "PC Short Blade", "33" }, - { "PC Sneak", "30" }, - { "PC Spear", "18" }, - { "PC Speechcraft", "36" }, - { "PC Speed", "54" }, // attrib - { "PC Strength", "10" }, // attrib - { "PC Unarmored", "28" }, - { "PC Vampire", "60" }, - { "PC Werewolf Kills", "73" }, - { "PC Willpower", "52" }, // attrib - { "Rank Requirement", "02" }, - { "Rank High", "01" }, - { "Rank Low", "00" }, - { "Reputation", "03" }, - { "Same Faction", "46" }, - { "Same Race", "45" }, - { "Same Sex", "44" }, - { "Should Attack", "71" }, - { "Talked To PC", "63" }, - { "Weather", "59" }, - { "Werewolf", "72" } - }; + static std::map populateInfoFuncToEnc() + { + std::map encMap; + encMap["Alarm"] = "69"; // AI + encMap["Alarmed"] = "49"; + encMap["Attacked"] = "62"; + encMap["Choice"] = "50"; + encMap["Creature Target"] = "65"; + encMap["Detected"] = "48"; + encMap["Faction Rank Difference"] ="47"; + encMap["Fight"] = "67"; // AI + encMap["Flee"] = "70"; // AI + encMap["Friend Hit"] = "66"; + encMap["Health Percent"] = "04"; + encMap["Hello"] = "68"; // AI + encMap["Level"] = "61"; + encMap["PC Acrobatics"] = "31"; + encMap["PC Agility"] = "53"; // attrib + encMap["PC Alchemy"] = "27"; + encMap["PC Alteration"] = "22"; + encMap["PC Armoror"] = "12"; + encMap["PC Athletics"] = "19"; + encMap["PC Axe"] = "17"; + encMap["PC Blight Disease"] = "41"; + encMap["PC Block"] = "11"; + encMap["PC Blunt Weapon"] = "15"; + encMap["PC Clothing Modifier"] = "42"; + encMap["PC Common Disease"] = "40"; + encMap["PC Conjuration"] = "24"; + encMap["PC Corpus"] = "58"; + encMap["PC Crime Level"] = "43"; + encMap["PC Destruction"] = "21"; + encMap["PC Enchant"] = "20"; + encMap["PC Endurance"] = "55"; // attrib + encMap["PC Expelled"] = "39"; + encMap["PC Fatigue"] = "09"; // dynamic stat + encMap["PC Hand To Hand"] = "37"; + encMap["PC Health"] = "64"; // dynamic stat + encMap["PC Health Percent"] = "07"; + encMap["PC Heavy Armor"] = "14"; + encMap["PC Illusion"] = "23"; + encMap["PC Intelligence"] = "51"; // attrib + encMap["PC Level"] = "06"; + encMap["PC Light Armor"] = "32"; + encMap["PC Long Blade"] = "16"; + encMap["PC Luck"] = "57"; // attrib + encMap["PC Magicka"] = "08"; // dynamic stat + encMap["PC Marksman"] = "34"; + encMap["PC Medium Armor"] = "13"; + encMap["PC Merchantile"] = "35"; + encMap["PC Mysticism"] = "25"; + encMap["PC Personality"] = "56"; // attrib + encMap["PC Reputation"] = "05"; + encMap["PC Restoration"] = "26"; + encMap["PC Security"] = "29"; + encMap["PC Sex"] = "38"; + encMap["PC Short Blade"] = "33"; + encMap["PC Sneak"] = "30"; + encMap["PC Spear"] = "18"; + encMap["PC Speechcraft"] = "36"; + encMap["PC Speed"] = "54"; // attrib + encMap["PC Strength"] = "10"; // attrib + encMap["PC Unarmored"] = "28"; + encMap["PC Vampire"] = "60"; + encMap["PC Werewolf Kills"] = "73"; + encMap["PC Willpower"] = "52"; // attrib + encMap["Rank Requirement"] = "02"; + encMap["Rank High"] = "01"; + encMap["Rank Low"] = "00"; + encMap["Reputation"] = "03"; + encMap["Same Faction"] = "46"; + encMap["Same Race"] = "45"; + encMap["Same Sex"] = "44"; + encMap["Should Attack"] = "71"; + encMap["Talked To PC"] = "63"; + encMap["Weather"] = "59"; + encMap["Werewolf"] = "72"; + return encMap; + } + static const std::map sInfoFuncToEnc = populateInfoFuncToEnc(); void InfoConditionAdapter::setData(Record& record, const QVariant& value, int subRowIndex, int subColIndex) const @@ -867,7 +873,7 @@ namespace CSMWorld if (conditions[subRowIndex].mSelectRule[1] == '1') { // throws an exception if the function is not found - const std::map::const_iterator it = sInfoFuncToEnc.find( + const std::map::const_iterator it = sInfoFuncToEnc.find( value.toString().toUtf8().constData()); if (it != sInfoFuncToEnc.end()) { From 587efcfe9db6f2fa6194971368b256cd006c1b49 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 10 May 2015 07:49:18 +1000 Subject: [PATCH 5/7] Use better initial value type. Fix exception while saving values. --- apps/opencs/model/world/nestedcoladapterimp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 8ee4af2f8a..8c62fb59b4 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -551,6 +551,7 @@ namespace CSMWorld ESM::DialInfo::SelectStruct condStruct; condStruct.mSelectRule = "00000"; condStruct.mValue = ESM::Variant(); + condStruct.mValue.setType(ESM::VT_Int); // default to ints conditions.insert(conditions.begin()+position, condStruct); @@ -688,6 +689,7 @@ namespace CSMWorld char condType = conditions[subRowIndex].mSelectRule[1]; switch (condType) { + case '0': return 0; // blank space case '1': return 1; // Function case '2': return 2; // Global case '3': return 3; // Local @@ -931,6 +933,7 @@ namespace CSMWorld } default: break; } + break; } default: throw std::runtime_error("Info condition subcolumn index out of range"); } From ab21c0551c6f5c3ccb63f6f2670a5f39c2c4294a Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 10 May 2015 13:34:45 +1000 Subject: [PATCH 6/7] Provide a default encoding when changing to "Function". --- apps/opencs/model/world/nestedcoladapterimp.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 8c62fb59b4..4c720ba24d 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -854,7 +854,14 @@ namespace CSMWorld { // FIXME: when these change the values of the other columns need to change // correspondingly (and automatically) - case 1: conditions[subRowIndex].mSelectRule[1] = '1'; break; // Function + case 1: + { + conditions[subRowIndex].mSelectRule[1] = '1'; // Function + // default to "Rank Low" + conditions[subRowIndex].mSelectRule[2] = '0'; + conditions[subRowIndex].mSelectRule[3] = '0'; + break; + } case 2: conditions[subRowIndex].mSelectRule[1] = '2'; break; // Global case 3: conditions[subRowIndex].mSelectRule[1] = '3'; break; // Local case 4: conditions[subRowIndex].mSelectRule[1] = '4'; break; // Journal @@ -874,7 +881,6 @@ namespace CSMWorld { if (conditions[subRowIndex].mSelectRule[1] == '1') { - // throws an exception if the function is not found const std::map::const_iterator it = sInfoFuncToEnc.find( value.toString().toUtf8().constData()); if (it != sInfoFuncToEnc.end()) From 2b84598e852694650d2fbe8886e7fea31131c793 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sun, 10 May 2015 20:52:29 +1000 Subject: [PATCH 7/7] Remove duplicated but reversed map. --- .../model/world/nestedcoladapterimp.cpp | 102 +++--------------- 1 file changed, 13 insertions(+), 89 deletions(-) diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 4c720ba24d..a0d7645767 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -754,87 +754,6 @@ namespace CSMWorld } } - static std::map populateInfoFuncToEnc() - { - std::map encMap; - encMap["Alarm"] = "69"; // AI - encMap["Alarmed"] = "49"; - encMap["Attacked"] = "62"; - encMap["Choice"] = "50"; - encMap["Creature Target"] = "65"; - encMap["Detected"] = "48"; - encMap["Faction Rank Difference"] ="47"; - encMap["Fight"] = "67"; // AI - encMap["Flee"] = "70"; // AI - encMap["Friend Hit"] = "66"; - encMap["Health Percent"] = "04"; - encMap["Hello"] = "68"; // AI - encMap["Level"] = "61"; - encMap["PC Acrobatics"] = "31"; - encMap["PC Agility"] = "53"; // attrib - encMap["PC Alchemy"] = "27"; - encMap["PC Alteration"] = "22"; - encMap["PC Armoror"] = "12"; - encMap["PC Athletics"] = "19"; - encMap["PC Axe"] = "17"; - encMap["PC Blight Disease"] = "41"; - encMap["PC Block"] = "11"; - encMap["PC Blunt Weapon"] = "15"; - encMap["PC Clothing Modifier"] = "42"; - encMap["PC Common Disease"] = "40"; - encMap["PC Conjuration"] = "24"; - encMap["PC Corpus"] = "58"; - encMap["PC Crime Level"] = "43"; - encMap["PC Destruction"] = "21"; - encMap["PC Enchant"] = "20"; - encMap["PC Endurance"] = "55"; // attrib - encMap["PC Expelled"] = "39"; - encMap["PC Fatigue"] = "09"; // dynamic stat - encMap["PC Hand To Hand"] = "37"; - encMap["PC Health"] = "64"; // dynamic stat - encMap["PC Health Percent"] = "07"; - encMap["PC Heavy Armor"] = "14"; - encMap["PC Illusion"] = "23"; - encMap["PC Intelligence"] = "51"; // attrib - encMap["PC Level"] = "06"; - encMap["PC Light Armor"] = "32"; - encMap["PC Long Blade"] = "16"; - encMap["PC Luck"] = "57"; // attrib - encMap["PC Magicka"] = "08"; // dynamic stat - encMap["PC Marksman"] = "34"; - encMap["PC Medium Armor"] = "13"; - encMap["PC Merchantile"] = "35"; - encMap["PC Mysticism"] = "25"; - encMap["PC Personality"] = "56"; // attrib - encMap["PC Reputation"] = "05"; - encMap["PC Restoration"] = "26"; - encMap["PC Security"] = "29"; - encMap["PC Sex"] = "38"; - encMap["PC Short Blade"] = "33"; - encMap["PC Sneak"] = "30"; - encMap["PC Spear"] = "18"; - encMap["PC Speechcraft"] = "36"; - encMap["PC Speed"] = "54"; // attrib - encMap["PC Strength"] = "10"; // attrib - encMap["PC Unarmored"] = "28"; - encMap["PC Vampire"] = "60"; - encMap["PC Werewolf Kills"] = "73"; - encMap["PC Willpower"] = "52"; // attrib - encMap["Rank Requirement"] = "02"; - encMap["Rank High"] = "01"; - encMap["Rank Low"] = "00"; - encMap["Reputation"] = "03"; - encMap["Same Faction"] = "46"; - encMap["Same Race"] = "45"; - encMap["Same Sex"] = "44"; - encMap["Should Attack"] = "71"; - encMap["Talked To PC"] = "63"; - encMap["Weather"] = "59"; - encMap["Werewolf"] = "72"; - return encMap; - } - static const std::map sInfoFuncToEnc = populateInfoFuncToEnc(); - void InfoConditionAdapter::setData(Record& record, const QVariant& value, int subRowIndex, int subColIndex) const { @@ -881,16 +800,21 @@ namespace CSMWorld { if (conditions[subRowIndex].mSelectRule[1] == '1') { - const std::map::const_iterator it = sInfoFuncToEnc.find( - value.toString().toUtf8().constData()); - if (it != sInfoFuncToEnc.end()) + std::map::const_iterator it = sEncToInfoFunc.begin(); + for (;it != sEncToInfoFunc.end(); ++it) { - std::string rule = conditions[subRowIndex].mSelectRule.substr(0, 2); - rule.append(it->second); - rule.append(std::string(1, conditions[subRowIndex].mSelectRule[4])); - conditions[subRowIndex].mSelectRule = rule.append(value.toString().toUtf8().constData()); + if (it->second == value.toString().toUtf8().constData()) + { + std::string rule = conditions[subRowIndex].mSelectRule.substr(0, 2); + rule.append(it->first); + // leave old values for undo (NOTE: may not be vanilla's behaviour) + rule.append(conditions[subRowIndex].mSelectRule.substr(4)); + conditions[subRowIndex].mSelectRule = rule; + break; + } } - else + + if (it == sEncToInfoFunc.end()) return; // return without saving; TODO: maybe log an error here } else