1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 21:23:52 +00:00

gmst id should be lowercase, wipe RecIdListT

This commit is contained in:
greye 2012-10-01 17:15:16 +04:00
parent 6f7a621b6f
commit f0a3ee0ef9
3 changed files with 19 additions and 69 deletions

View file

@ -2,6 +2,8 @@
#include <stdexcept> #include <stdexcept>
#include <boost/algorithm/string.hpp>
#include "esmreader.hpp" #include "esmreader.hpp"
#include "esmwriter.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. /// working properly in its current state and I doubt it can be fixed without breaking other stuff.
// Some handy macros // Some handy macros
#define cI(s,x) { if(mId == (s)) return (mI == (x)); } #define cI(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mI == (x)); }
#define cF(s,x) { if(mId == (s)) return (mF == (x)); } #define cF(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mF == (x)); }
#define cS(s,x) { if(mId == (s)) return (mStr == (x)); } #define cS(s,x) { label = (s); boost::algorithm::to_lower(label); if (mId == label) return (mStr == (x)); }
bool GameSetting::isDirtyTribunal() bool GameSetting::isDirtyTribunal()
{ {
@ -28,6 +30,7 @@ bool GameSetting::isDirtyTribunal()
from other mods. from other mods.
*/ */
std::string label;
// Strings // Strings
cS("sProfitValue", "Profit Value"); // 'Profit:' cS("sProfitValue", "Profit Value"); // 'Profit:'
cS("sEditNote", "Edit Note"); // same cS("sEditNote", "Edit Note"); // same
@ -51,13 +54,14 @@ bool GameSetting::isDirtyTribunal()
// [The difference here is "Profit Value" -> "Profit"] // [The difference here is "Profit Value" -> "Profit"]
// Strings that matches the mId // Strings that matches the mId
cS("sEffectSummonFabricant", mId);// 'Summon Fabricant' cS("sEffectSummonFabricant", "sEffectSummonFabricant");// 'Summon Fabricant'
return false; return false;
} }
// Bloodmoon variant // Bloodmoon variant
bool GameSetting::isDirtyBloodmoon() bool GameSetting::isDirtyBloodmoon()
{ {
std::string label;
// Strings // Strings
cS("sWerewolfPopup", "Werewolf"); // same cS("sWerewolfPopup", "Werewolf"); // same
cS("sWerewolfRestMessage", cS("sWerewolfRestMessage",
@ -69,16 +73,16 @@ bool GameSetting::isDirtyBloodmoon()
// 'You have been detected as a known werewolf.' // 'You have been detected as a known werewolf.'
// Strings that matches the mId // Strings that matches the mId
cS("sMagicCreature01ID", mId); // 'BM_wolf_grey_summon' cS("sMagicCreature01ID", "sMagicCreature01ID"); // 'BM_wolf_grey_summon'
cS("sMagicCreature02ID", mId); // 'BM_bear_black_summon' cS("sMagicCreature02ID", "sMagicCreature02ID"); // 'BM_bear_black_summon'
cS("sMagicCreature03ID", mId); // 'BM_wolf_bone_summon' cS("sMagicCreature03ID", "sMagicCreature03ID"); // 'BM_wolf_bone_summon'
cS("sMagicCreature04ID", mId); // same cS("sMagicCreature04ID", "sMagicCreature04ID"); // same
cS("sMagicCreature05ID", mId); // same cS("sMagicCreature05ID", "sMagicCreature05ID"); // same
cS("sEffectSummonCreature01", mId); // 'Calf Wolf' cS("sEffectSummonCreature01", "sEffectSummonCreature01"); // 'Calf Wolf'
cS("sEffectSummonCreature02", mId); // 'Calf Bear' cS("sEffectSummonCreature02", "sEffectSummonCreature02"); // 'Calf Bear'
cS("sEffectSummonCreature03", mId); // 'Summon Bonewolf' cS("sEffectSummonCreature03", "sEffectSummonCreature03"); // 'Summon Bonewolf'
cS("sEffectSummonCreature04", mId); // same cS("sEffectSummonCreature04", "sEffectSummonCreature04"); // same
cS("sEffectSummonCreature05", mId); // same cS("sEffectSummonCreature05", "sEffectSummonCreature05"); // same
// Integers // Integers
cI("iWereWolfBounty", 10000); // 1000 cI("iWereWolfBounty", 10000); // 1000

View file

@ -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 /* Land textures are indexed by an integer number
*/ */
struct LTexList : RecList struct LTexList : RecList

View file

@ -68,7 +68,7 @@ namespace ESMS
// Lists that need special rules // Lists that need special rules
CellList cells; CellList cells;
RecIDListT<GameSetting> gameSettings; RecListWithIDT<GameSetting> gameSettings;
LandList lands; LandList lands;
LTexList landTexts; LTexList landTexts;
ScriptListT<Script> scripts; ScriptListT<Script> scripts;