From d7dcd6e525385c5c8c2a814dbf9ea3f035ad5ff2 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Sun, 18 Aug 2013 17:05:11 +0100 Subject: [PATCH] More libespm-related changes. --- src/backend/game.h | 2 +- src/backend/metadata.cpp | 92 +++++++++++++++++++++------------------- 2 files changed, 50 insertions(+), 44 deletions(-) diff --git a/src/backend/game.h b/src/backend/game.h index 4ecdeda0..0313c850 100644 --- a/src/backend/game.h +++ b/src/backend/game.h @@ -34,7 +34,7 @@ #include #include -#include +#include namespace boss { diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index b2b9ba78..9abff60c 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -25,7 +25,7 @@ #include "metadata.h" #include "parsers.h" -#include +#include #include #include @@ -270,15 +270,23 @@ namespace boss { boost::filesystem::path filepath = game.DataPath() / name; if (!boost::filesystem::exists(filepath) && boost::filesystem::exists(filepath.string() + ".ghost")) filepath += ".ghost"; - espm::File file(filepath, game.espm_settings, false, headerOnly); + espm::File * file; + if (game.Id() == g_game_tes4) + file = new espm::tes4::File(filepath, game.espm_settings, false, headerOnly); + else if (game.Id() == g_game_tes5) + file = new espm::tes5::File(filepath, game.espm_settings, false, headerOnly); + else if (game.Id() == g_game_fo3) + file = new espm::fo3::File(filepath, game.espm_settings, false, headerOnly); + else + file = new espm::fonv::File(filepath, game.espm_settings, false, headerOnly); - isMaster = file.isMaster(game.espm_settings); - masters = file.getMasters(); + isMaster = file->isMaster(game.espm_settings); + masters = file->getMasters(); - crc = file.crc; + crc = file->crc; game.crcCache.insert(pair(n, crc)); - vector records = file.getFormIDs(); + vector records = file->getFormIDs(); vector plugins = masters; plugins.push_back(name); for (vector::const_iterator it = records.begin(),endIt = records.end(); it != endIt; ++it) @@ -291,51 +299,49 @@ namespace boss { } //Also read Bash Tags applied and version string in description. - for(size_t i=0,max=file.fields.size(); i < max; ++i){ - if (strncmp(file.fields[i].type,"SNAM", 4) == 0) { - string text = file.fields[i].data; + string text = file->getDescription(); - string::const_iterator begin, end; - begin = text.begin(); - end = text.end(); + delete file; - for(int j = 0; j < 7 && version.empty(); j++) { - boost::smatch what; - while (boost::regex_search(begin, end, what, version_checks[j])) { - if (what.empty()) - continue; + string::const_iterator begin, end; + begin = text.begin(); + end = text.end(); - boost::ssub_match match = what[1]; - if (!match.matched) - continue; + for(int j = 0; j < 7 && version.empty(); j++) { + boost::smatch what; + while (boost::regex_search(begin, end, what, version_checks[j])) { + if (what.empty()) + continue; - version = boost::trim_copy(string(match.first, match.second)); - break; - } - } - - size_t pos1 = text.find("{{BASH:"); - if (pos1 == string::npos) - break; - - pos1 += 7; - - size_t pos2 = text.find("}}", pos1); - if (pos2 == string::npos) - break; - - text = text.substr(pos1, pos2-pos1); - - vector bashTags; - boost::split(bashTags, text, boost::is_any_of(",")); - - for (int i=0,max=bashTags.size(); i bashTags; + boost::split(bashTags, text, boost::is_any_of(",")); + + for (int i=0,max=bashTags.size(); i