1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-22 00:53:50 +00:00

Make the text keys lower-case when extracting them

I think it's safe to assume all text keys are treated in a case-insensitive
manner. So far the only known NiTextKeyExtraData records are for animation
keys, which effectively are.
This commit is contained in:
Chris Robinson 2013-01-09 00:17:42 -08:00
parent 9675a6d04a
commit e44729cd43
2 changed files with 9 additions and 9 deletions

View file

@ -75,11 +75,6 @@ void Animation::createEntityList(Ogre::SceneNode *node, const std::string &model
if(mTextKeys.size() > 0) if(mTextKeys.size() > 0)
{ {
NifOgre::TextKeyMap::iterator keyiter;
for(keyiter = mTextKeys.begin();keyiter != mTextKeys.end();keyiter++)
std::transform(keyiter->second.begin(), keyiter->second.end(),
keyiter->second.begin(), ::tolower);
Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates(); Ogre::AnimationStateSet *aset = mEntityList.mSkelBase->getAllAnimationStates();
Ogre::AnimationStateIterator as = aset->getAnimationStateIterator(); Ogre::AnimationStateIterator as = aset->getAnimationStateIterator();
while(as.hasMoreElements()) while(as.hasMoreElements())

View file

@ -286,13 +286,18 @@ static TextKeyMap extractTextKeys(const Nif::NiTextKeyExtraData *tk)
std::string::size_type pos = 0; std::string::size_type pos = 0;
while(pos < str.length()) while(pos < str.length())
{ {
while(pos < str.length() && ::isspace(str[pos])) if(::isspace(str[pos]))
{
pos++; pos++;
if(pos >= str.length()) continue;
break; }
std::string::size_type nextpos = std::min(str.find('\r', pos), str.find('\n', pos)); std::string::size_type nextpos = std::min(str.find('\r', pos), str.find('\n', pos));
textkeys.insert(std::make_pair(tk->list[i].time, str.substr(pos, nextpos-pos))); std::string result;
result.reserve(str.length());
std::transform(str.begin()+pos, str.begin()+std::min(str.length(), nextpos),
std::back_inserter(result), ::tolower);
textkeys.insert(std::make_pair(tk->list[i].time, result));
pos = nextpos; pos = nextpos;
} }