X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcategory.cpp;h=5e454bb9dc7af7dcef5843efa9b4a3b96761404c;hb=8b9d1f472e7bfbb1e097bb6d8bcad026e9636822;hp=4ceed1883df32f7e971bd8dcb594795f64fa831c;hpb=0388bdcffe5c2c3e720afa9aa911268eac9c32de;p=poefilter.git diff --git a/source/category.cpp b/source/category.cpp index 4ceed18..5e454bb 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,11 @@ void Category::create_statements(list &st) const st.push_back(FilterStatement()); if(condition) - condition->add_lines(st); + { + Condition *flat = condition->flatten(); + flat->add_lines(st); + delete flat; + } } @@ -54,6 +63,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 +72,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 +111,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) {