X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcategory.cpp;h=0f6eb3f57e962ab0021b7b238aabff1a2470b571;hb=7d7eaf754af04f81bb1e7a8872272ea15e01d0c4;hp=4ceed1883df32f7e971bd8dcb594795f64fa831c;hpb=0388bdcffe5c2c3e720afa9aa911268eac9c32de;p=poefilter.git diff --git a/source/category.cpp b/source/category.cpp index 4ceed18..0f6eb3f 100644 --- a/source/category.cpp +++ b/source/category.cpp @@ -8,12 +8,17 @@ using namespace std; using namespace Msp; -Category::Category(const string &n): - name(n), +Category::Category(): condition(0), order(0) { } +Category::Category(const string &n, unsigned o): + name(n), + condition(0), + order(o) +{ } + Category::Category(const Category &other): name(other.name), condition(other.condition ? other.condition->clone() : 0), @@ -42,7 +47,15 @@ void Category::create_statements(list &st) const st.push_back(FilterStatement()); if(condition) - condition->add_lines(st); + { + Condition *flat = condition->flatten(); + if(flat) + { + flat->add_lines(st); + delete flat; + } + // TODO handle the case of the entire condition being non-viable + } } @@ -54,6 +67,7 @@ Category::Loader::Loader(Category &c, const PoeFilter &p, CompoundCondition *n): { add("and", &Loader::and_); add("base_type", &Loader::condition); + add("category", &Loader::category); add("class", &Loader::condition); add_range("drop_level"); add_range("height"); @@ -62,7 +76,6 @@ Category::Loader::Loader(Category &c, const PoeFilter &p, CompoundCondition *n): add_range("linked_sockets"); add_range("sockets"); add("or", &Loader::or_); - add("order", &Category::order); add_range("quality"); add_range("rarity"); add_range("width"); @@ -102,6 +115,12 @@ void Category::Loader::and_() add_condition(cond.release()); } +void Category::Loader::category(const string &name) +{ + const Category &categ = poe.get_category(name); + add_condition(categ.condition->clone()); +} + template void Category::Loader::condition(typename T::Type value) {