**********************************************************

** Big Maps Projects code (incl. Multiplayer v1.5 **
**********************************************************
- Merged Big Maps Project code from BMP+MP trunk (Revision: 3340)
o Complete SVN Revision history: https://81.169.133.124/source/ja2/branches/Wanne/JA2%201.13%20MP
- Before THIS merge, I made a branch of the existing 1.13 source
o SVN Branch: https://81.169.133.124/source/ja2/branches/JA2_rev.3336/src
- Removed old VS 6.0 and VS 2003 project and solutions files, because compilation is broken long time ago
- I will add VS 2010 projects and solution file in the next few days

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@3341 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Wanne
2010-02-28 18:38:52 +00:00
parent a98c44ac78
commit 14750c6903
461 changed files with 23615 additions and 120157 deletions
+38 -38
View File
@@ -15,7 +15,7 @@ CPropertyContainer::TagMap::TagMap()
_map[L"Key"] = L"Key";
_map[L"KeyID"] = L"name";
}
utf8string const& CPropertyContainer::TagMap::Container(utf8string::char_t* container)
utf8string const& CPropertyContainer::TagMap::container(utf8string::char_t* container)
{
if(container)
{
@@ -23,7 +23,7 @@ utf8string const& CPropertyContainer::TagMap::Container(utf8string::char_t* cont
}
return _map[L"Container"];
}
utf8string const& CPropertyContainer::TagMap::Section(utf8string::char_t* section)
utf8string const& CPropertyContainer::TagMap::section(utf8string::char_t* section)
{
if(section)
{
@@ -31,7 +31,7 @@ utf8string const& CPropertyContainer::TagMap::Section(utf8string::char_t* sectio
}
return _map[L"Section"];
}
utf8string const& CPropertyContainer::TagMap::SectionID(utf8string::char_t* section_id)
utf8string const& CPropertyContainer::TagMap::sectionID(utf8string::char_t* section_id)
{
if(section_id)
{
@@ -39,7 +39,7 @@ utf8string const& CPropertyContainer::TagMap::SectionID(utf8string::char_t* sect
}
return _map[L"SectionID"];
}
utf8string const& CPropertyContainer::TagMap::Key(utf8string::char_t* key)
utf8string const& CPropertyContainer::TagMap::key(utf8string::char_t* key)
{
if(key)
{
@@ -47,7 +47,7 @@ utf8string const& CPropertyContainer::TagMap::Key(utf8string::char_t* key)
}
return _map[L"Key"];
}
utf8string const& CPropertyContainer::TagMap::KeyID(utf8string::char_t* key_id)
utf8string const& CPropertyContainer::TagMap::keyID(utf8string::char_t* key_id)
{
if(key_id)
{
@@ -56,33 +56,33 @@ utf8string const& CPropertyContainer::TagMap::KeyID(utf8string::char_t* key_id)
return _map[L"KeyID"];
}
bool CPropertyContainer::WriteToXMLFile(vfs::Path const& sFileName, CPropertyContainer::TagMap& tagmap)
bool CPropertyContainer::writeToXMLFile(vfs::Path const& sFileName, CPropertyContainer::TagMap& tagmap)
{
XMLWriter xmlw;
xmlw.OpenNode(tagmap.Container());
xmlw.openNode(tagmap.container());
tSections::iterator sit = m_mapProps.begin();
for(; sit != m_mapProps.end(); ++sit)
{
xmlw.AddAttributeToNextValue(tagmap.SectionID(),sit->first.utf8());
xmlw.OpenNode(tagmap.Section());
xmlw.addAttributeToNextValue(tagmap.sectionID(),sit->first.utf8());
xmlw.openNode(tagmap.section());
CPropertyContainer::CSection& section = sit->second;
CPropertyContainer::CSection::tProps::iterator kit = section.mapProps.begin();
for(; kit != section.mapProps.end(); ++kit)
{
xmlw.AddAttributeToNextValue(tagmap.KeyID(), kit->first.utf8());
xmlw.AddValue(tagmap.Key(), kit->second.utf8());
xmlw.addAttributeToNextValue(tagmap.keyID(), kit->first.utf8());
xmlw.addValue(tagmap.key(), kit->second.utf8());
}
xmlw.CloseNode();
xmlw.closeNode();
}
xmlw.CloseNode();
xmlw.closeNode();
return xmlw.WriteToFile(sFileName);
return xmlw.writeToFile(sFileName);
}
/*********************************************************************************/
@@ -108,9 +108,9 @@ public:
_tagmap(tagmap),
current_state(DO_ELEMENT_NONE) // doesn't matter where we come from, we start fresh
{};
virtual void OnStartElement(const XML_Char* name, const XML_Char** atts);
virtual void OnEndElement(const XML_Char* name);
virtual void OnTextElement(const XML_Char *str, int len);
virtual void onStartElement(const XML_Char* name, const XML_Char** atts);
virtual void onEndElement(const XML_Char* name);
virtual void onTextElement(const XML_Char *str, int len);
private:
CPropertyContainer& _container;
CPropertyContainer::TagMap& _tagmap;
@@ -120,45 +120,45 @@ private:
};
void CPropertyXMLParser::OnStartElement(const XML_Char *name, const XML_Char **atts)
void CPropertyXMLParser::onStartElement(const XML_Char *name, const XML_Char **atts)
{
utf8string utf8_name(name);
if(current_state == DO_ELEMENT_NONE && StrCmp::Equal(utf8_name,_tagmap.Container()))
if(current_state == DO_ELEMENT_NONE && StrCmp::Equal(utf8_name,_tagmap.container()))
{
current_state = DO_ELEMENT_Container;
}
else if(current_state == DO_ELEMENT_Container && StrCmp::Equal(utf8_name, _tagmap.Section()))
else if(current_state == DO_ELEMENT_Container && StrCmp::Equal(utf8_name, _tagmap.section()))
{
current_state = DO_ELEMENT_Section;
current_section = this->GetAttribute(_tagmap.SectionID().utf8().c_str(),atts);
current_section = this->getAttribute(_tagmap.sectionID().utf8().c_str(),atts);
}
else if(current_state == DO_ELEMENT_Section && StrCmp::Equal(utf8_name, _tagmap.Key()))
else if(current_state == DO_ELEMENT_Section && StrCmp::Equal(utf8_name, _tagmap.key()))
{
current_state = DO_ELEMENT_Key;
current_key = this->GetAttribute(_tagmap.KeyID().utf8().c_str(),atts);
current_key = this->getAttribute(_tagmap.keyID().utf8().c_str(),atts);
}
sCharData = "";
}
void CPropertyXMLParser::OnEndElement(const XML_Char* name)
void CPropertyXMLParser::onEndElement(const XML_Char* name)
{
utf8string utf8_name(name);
if(current_state == DO_ELEMENT_Key && StrCmp::Equal(utf8_name, _tagmap.Key()))
if(current_state == DO_ELEMENT_Key && StrCmp::Equal(utf8_name, _tagmap.key()))
{
_container.SetStringProperty(current_section, current_key, vfs::TrimString(sCharData,0,sCharData.length()));
_container.setStringProperty(current_section, current_key, vfs::trimString(sCharData,0,sCharData.length()));
current_state = DO_ELEMENT_Section;
}
else if(current_state == DO_ELEMENT_Section && StrCmp::Equal(utf8_name, _tagmap.Section()))
else if(current_state == DO_ELEMENT_Section && StrCmp::Equal(utf8_name, _tagmap.section()))
{
current_state = DO_ELEMENT_Container;
}
else if(current_state == DO_ELEMENT_Container && StrCmp::Equal(utf8_name, _tagmap.Container()))
else if(current_state == DO_ELEMENT_Container && StrCmp::Equal(utf8_name, _tagmap.container()))
{
current_state = DO_ELEMENT_NONE;
}
}
void CPropertyXMLParser::OnTextElement(const XML_Char *str, int len)
void CPropertyXMLParser::onTextElement(const XML_Char *str, int len)
{
if(current_state == DO_ELEMENT_Key)
{
@@ -166,7 +166,7 @@ void CPropertyXMLParser::OnTextElement(const XML_Char *str, int len)
}
}
bool CPropertyContainer::InitFromXMLFile(vfs::Path const& sFileName, CPropertyContainer::TagMap& tagmap)
bool CPropertyContainer::initFromXMLFile(vfs::Path const& sFileName, CPropertyContainer::TagMap& tagmap)
{
vfs::tReadableFile *file = NULL;
bool delete_file = false;
@@ -178,12 +178,13 @@ bool CPropertyContainer::InitFromXMLFile(vfs::Path const& sFileName, CPropertyCo
}
catch(CBasicException& ex)
{
logException(ex);
vfs::CFile* rfile = new vfs::CFile(sFileName);
delete_file = true;
file = vfs::tReadableFile::Cast(rfile);
if(!file->OpenRead())
file = vfs::tReadableFile::cast(rfile);
if(!file->openRead())
{
file->Close();
file->close();
delete file;
return false;
}
@@ -193,21 +194,20 @@ bool CPropertyContainer::InitFromXMLFile(vfs::Path const& sFileName, CPropertyCo
return false;
}
vfs::UInt32 size = file->GetFileSize();
vfs::size_t size = file->getSize();
std::vector<vfs::Byte> buffer(size+1);
vfs::UInt32 has_read;
file->Read(&buffer[0],size,has_read);
TRYCATCH_RETHROW( file->read(&buffer[0],size), L"" );
buffer[size] = 0;
file->Close();
file->close();
if(delete_file) delete file;
XML_Parser parser = XML_ParserCreate(NULL);
CPropertyXMLParser pp(*this,tagmap,parser,NULL);
pp.GrabParser();
pp.grabParser();
if(!XML_Parse(parser, &buffer[0], size, TRUE))
{