From 7be1a35d77d14fc090126426a11aad545d54fe51 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Sun, 15 Mar 2015 13:23:23 -0600 Subject: [PATCH] Fixed IniFile::RenameKey by adding RenameChildInByName to XmlFile. Only font loading uses RenameKey. --- src/Font.cpp | 5 +++-- src/IniFile.cpp | 1 + src/XmlFile.cpp | 6 ++++++ src/XmlFile.h | 1 + 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Font.cpp b/src/Font.cpp index c7e7f547ce..2d46908580 100644 --- a/src/Font.cpp +++ b/src/Font.cpp @@ -606,11 +606,12 @@ void Font::LoadFontPageSettings( FontPageSettings &cfg, IniFile &ini, const RStr const int row = StringToInt(row_str); const int first_frame = row * num_frames_wide; - if(row > num_frames_high) + if(row >= num_frames_high) { LuaHelpers::ReportScriptErrorFmt( "The font definition \"%s\" tries to assign line %i, " - "but the font is only %i characters high.", + "but the font is only %i characters high." + "Line numbers start at 0.", ini.GetPath().c_str(), first_frame, num_frames_high); continue; } diff --git a/src/IniFile.cpp b/src/IniFile.cpp index a4766f509d..869218dec3 100644 --- a/src/IniFile.cpp +++ b/src/IniFile.cpp @@ -188,6 +188,7 @@ bool IniFile::RenameKey(const RString &from, const RString &to) return false; pNode->SetName( to ); + RenameChildInByName(pNode); return true; } diff --git a/src/XmlFile.cpp b/src/XmlFile.cpp index 1b302065b1..b57ec74b16 100644 --- a/src/XmlFile.cpp +++ b/src/XmlFile.cpp @@ -169,6 +169,12 @@ void XNode::RemoveChildFromByName(XNode* node) } } +void XNode::RenameChildInByName(XNode* node) +{ + RemoveChildFromByName(node); + m_children_by_name.insert(make_pair(node->m_sName, node)); +} + // detach attribute bool XNode::RemoveAttr( const RString &sName ) diff --git a/src/XmlFile.h b/src/XmlFile.h index 58b0014391..5b15b8de69 100644 --- a/src/XmlFile.h +++ b/src/XmlFile.h @@ -124,6 +124,7 @@ public: XNode *AppendChild( XNode *node ); bool RemoveChild( XNode *node, bool bDelete = true ); void RemoveChildFromByName(XNode *node); + void RenameChildInByName(XNode* node); XNodeValue *AppendAttrFrom( const RString &sName, XNodeValue *pValue, bool bOverwrite = true ); XNodeValue *AppendAttr( const RString &sName );