--- deliantra/server/lib/cf/match.pm 2009/10/11 23:51:47 1.13 +++ deliantra/server/lib/cf/match.pm 2009/10/12 21:27:55 1.18 @@ -112,16 +112,20 @@ Replaces all objects by their containing object, if they have one. +=item in arch + +Replaces all objects by their archetypes. + =item in map Replaces all objects by the objects that are on the same mapspace as them. -=item in +=item in Finds all context objects matching the condition, and then puts their inventories into the context set. -Note that C is simply a special case of an C<< in >> that +Note that C is simply a special case of an C<< in >> that matches any object. Example: find all spells inside potions inside the inventory of the context @@ -138,14 +142,17 @@ type=SPELL also in inv -=item deep in ... +=item also deep in ... Repeats the operation as many times as possible. This can be used to recursively look into objects. -=item also deep in ... +So for example, C means to take the inventory of all +objects, taking their inventories, and so on, and adding all these objects +to the context set. -C and C can be combined. +Similarly, C means to take the environment object, their +environemnt object and so on. Example: check if there are any unpaid items in an inventory, or in the inventories of the inventory objects, and so on. @@ -289,14 +296,14 @@ An independent match - semantics like C, except it only matters whether the match finds any object (which is faster). -=item dump +=item dump() Dumps the object to the server log when executed, and evaluates to true. Note that logical operations are short-circuiting, so this only dumps potions: - type=POTION and dump + type=POTION and dump() =back @@ -315,18 +322,18 @@ | chain also deep 'in' set also = nothing | 'also' deep = nothing | 'deep' - set = 'inv' | 'env' | 'map' + set = 'inv' | 'env' | 'arch' | 'map' empty = # boolean matching condition condition = factor - | factor 'and'? cond - | factor 'or' cond + | factor 'and'? condition + | factor 'or' condition factor = 'not' factor - | '(' cond ')' + | '(' condition ')' | expr | expr operator constant @@ -393,12 +400,6 @@ local $all = 0; '(scalar ' . &match ('$_') . ')' }, - ); - - our %special = ( - any => sub { - 1 - }, dump => sub { 'do { warn "cf::match::match dump:\n" @@ -409,6 +410,12 @@ }, ); + our %special = ( + any => sub { + 1 + }, + ); + sub constant { ws; @@ -529,7 +536,8 @@ ws; # first check some stop-symbols, so we don't have to backtrack - if (/\G(?=also\b|deep\b|in\b|of\b\)|$)/gc) { + if (/\G(?=also\b|deep\b|in\b|of\b\)|\z)/gc) { + pos = pos; # argh. the misop hits again. again. again. again. you die. last; } elsif (/\Gor\b/gc) { @@ -559,13 +567,17 @@ if (/\Gin\s+/gc) { my $expand; - if (/\G(inv|env|map)\b/gc) { + if (/\G(inv|env|map|arch)\b/gc) { if ($1 eq "inv") { $expand = "map \$_->inv,"; } elsif ($1 eq "env") { $expand = "map \$_->env // (),"; + } elsif ($1 eq "arch") { + $expand = "map \$_->arch,"; + $deep = 0; # infinite loop otherwise } elsif ($1 eq "map") { $expand = "map \$_->map->at (\$_->x, \$_->y),"; + $deep = 0; # infinite loop otherwise } } else { $expand = "map \$_->inv, grep { " . condition . " }"; @@ -612,7 +624,7 @@ eval { $res = cf::match::parser::match "\$object"; - /\G\s*$/gc + /\G$/gc or die "unexpected trailing characters after match\n"; }; @@ -629,7 +641,7 @@ } if (0) {#d# - die parse 'applied', 1; + die parse 'type=SPELL_EFFECT and match(name="bullet" in arch)', 1; exit 0; } @@ -673,6 +685,10 @@ } } +our $CACHE_CLEARER = AE::timer 3600, 3600, sub { + %CACHE = (); +}; + #d# $::schmorp=cf::player::find "schmorp"& #d# cf::match::match '', $::schmorp->ob