From 0485bd935b235e1162332ca145e7fbb6e5aecb3b Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 14 Jan 2010 14:11:27 +0000 Subject: Made EntityList able to handle several files with same macroname and version number, without corrupting the internal data structure (switched from map to multimap). --- server/src/entitylist.cc | 4 ++-- server/src/entitylist.h | 3 ++- server/src/macrolist.cc | 5 ++++- server/src/templatelist.cc | 3 ++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/src/entitylist.cc b/server/src/entitylist.cc index 64bd49d..b84df61 100644 --- a/server/src/entitylist.cc +++ b/server/src/entitylist.cc @@ -139,8 +139,8 @@ bool EntityList::removeFile(std::string file) while(j != i->second.end()) { if(file == j->second) { PRACRO_DEBUG(entitylist, "Removing file: %s\n", file.c_str()); - i->second.erase(j->first); - if(i->second.size() == 0) erase(i->first); + i->second.erase(j); + if(i->second.size() == 0) erase(i); return true; } j++; diff --git a/server/src/entitylist.h b/server/src/entitylist.h index b596c07..9185f67 100644 --- a/server/src/entitylist.h +++ b/server/src/entitylist.h @@ -30,6 +30,7 @@ #include #include + #include "versionstr.h" #include "mutex.h" @@ -40,7 +41,7 @@ /** * The Items contained in the EntityList. */ -typedef std::map EntityListItem; +typedef std::multimap EntityListItem; /** * The EntityList class is intended for entity file caching, so that all entitys diff --git a/server/src/macrolist.cc b/server/src/macrolist.cc index 86584d4..9dadb12 100644 --- a/server/src/macrolist.cc +++ b/server/src/macrolist.cc @@ -27,6 +27,8 @@ */ #include "macrolist.h" +#include + #include "macroheaderparser.h" #include "debug.h" @@ -45,7 +47,8 @@ void MacroList::addFile(std::string file) try { parser.parse(); Macro *macro = parser.getMacro(); - (*this)[macro->attributes["name"]][VersionStr(macro->attributes["version"])] = file; + std::pair p(VersionStr(macro->attributes["version"]), file); + (*this)[macro->attributes["name"]].insert(p); } catch(Exception &e) { PRACRO_WARN(macrolist, "Skipping %s: %s\n", file.c_str(), e.what()); } diff --git a/server/src/templatelist.cc b/server/src/templatelist.cc index b952467..0fc8ec5 100644 --- a/server/src/templatelist.cc +++ b/server/src/templatelist.cc @@ -44,7 +44,8 @@ void TemplateList::addFile(std::string file) try { parser.parse(); Template *templ = parser.getTemplate(); - (*this)[templ->attributes["name"]][VersionStr(templ->attributes["version"])] = file; + std::pair p(VersionStr(templ->attributes["version"]), file); + (*this)[templ->attributes["name"]].insert(p); } catch(Exception &e) { PRACRO_WARN(templatelist, "Skipping %s: %s\n", file.c_str(), e.what()); } -- cgit v1.2.3