… | |
… | |
162 | |
162 | |
163 | use overload |
163 | use overload |
164 | '=' => sub { bless [@{$_[0]}], ref $_[0] }, |
164 | '=' => sub { bless [@{$_[0]}], ref $_[0] }, |
165 | '""' => \&as_string, |
165 | '""' => \&as_string, |
166 | '>=' => sub { $_[0][0] & $MOVE_TYPE{$_[1]} ? $_[0][1] & $MOVE_TYPE{$_[1]} : undef }, |
166 | '>=' => sub { $_[0][0] & $MOVE_TYPE{$_[1]} ? $_[0][1] & $MOVE_TYPE{$_[1]} : undef }, |
|
|
167 | '<=' => sub { |
|
|
168 | ($_[0][0] & $MOVE_TYPE{$_[1]}) == $MOVE_TYPE{$_[1]} |
|
|
169 | ? $_[0][1] & $MOVE_TYPE{$_[1]} |
|
|
170 | : undef |
|
|
171 | }, |
167 | '+=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] |= $MOVE_TYPE{$_[1]}; &normalise }, |
172 | '+=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] |= $MOVE_TYPE{$_[1]}; &normalise }, |
168 | '-=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
173 | '-=' => sub { $_[0][0] |= $MOVE_TYPE{$_[1]}; $_[0][1] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
169 | '/=' => sub { $_[0][0] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
174 | '/=' => sub { $_[0][0] &= ~$MOVE_TYPE{$_[1]}; &normalise }, |
170 | 'x=' => sub { |
175 | 'x=' => sub { # toggle between off, + and - |
171 | my $cur = $_[0] >= $_[1]; |
176 | my $cur = $_[0] >= $_[1]; |
172 | if (!defined $cur) { |
177 | if (!defined $cur) { |
173 | if ($_[0] >= "all") { |
178 | if ($_[0] >= "all") { |
174 | $_[0] -= $_[1]; |
179 | $_[0] -= $_[1]; |
175 | } else { |
180 | } else { |
… | |
… | |
339 | |
344 | |
340 | # object as in "Object xxx", i.e. archetypes |
345 | # object as in "Object xxx", i.e. archetypes |
341 | sub normalize_object($) { |
346 | sub normalize_object($) { |
342 | my ($ob) = @_; |
347 | my ($ob) = @_; |
343 | |
348 | |
|
|
349 | delete $ob->{editable}; # deprecated |
|
|
350 | |
344 | # convert material bitset to materialname, if possible |
351 | # convert material bitset to materialname, if possible |
345 | if (exists $ob->{material}) { |
352 | if (exists $ob->{material}) { |
346 | if (!$ob->{material}) { |
353 | if (!$ob->{material}) { |
347 | delete $ob->{material}; |
354 | delete $ob->{material}; |
348 | } elsif (exists $ob->{materialname}) { |
355 | } elsif (exists $ob->{materialname}) { |
… | |
… | |
808 | $root = $Deliantra::Data::TYPE{Misc}; |
815 | $root = $Deliantra::Data::TYPE{Misc}; |
809 | } |
816 | } |
810 | } |
817 | } |
811 | |
818 | |
812 | my @import = ($root); |
819 | my @import = ($root); |
813 | |
820 | |
814 | unshift @import, \%Deliantra::Data::DEFAULT_ATTR |
821 | unshift @import, \%Deliantra::Data::DEFAULT_ATTR |
815 | unless $type == 116; |
822 | unless $type == 116; |
816 | |
823 | |
817 | my (%ignore); |
824 | my (%ignore); |
818 | my (@section_order, %section, @attr_order); |
825 | my (@section_order, %section, @attr_order); |
… | |
… | |
839 | $section{$name}{$k} ||= $v; |
846 | $section{$name}{$k} ||= $v; |
840 | } |
847 | } |
841 | } |
848 | } |
842 | } |
849 | } |
843 | |
850 | |
|
|
851 | # remove ignores for "root" type |
|
|
852 | for (map @{$_->[1]}, # section attributes |
|
|
853 | [general => ($root->{attr} || [])], |
|
|
854 | @{$root->{section} || []}) |
|
|
855 | { |
|
|
856 | my ($k, $v) = @$_; |
|
|
857 | # skip fixed attributes, if they are ignored thats fine |
|
|
858 | next if $v->{type} eq 'fixed'; |
|
|
859 | |
|
|
860 | delete $ignore{$k}; # if the attributes are defined explicitly they |
|
|
861 | # should NOT be ignored. ignore should mainly |
|
|
862 | # hit imported/inherited attributes. |
|
|
863 | } |
|
|
864 | |
844 | $attr->{section} = [ |
865 | $attr->{section} = [ |
845 | map !exists $section{$_} ? () : do { |
866 | map !exists $section{$_} ? () : do { |
846 | my $attr = delete $section{$_}; |
867 | my $attr = delete $section{$_}; |
847 | |
868 | |
848 | [ |
869 | [ |
… | |
… | |
850 | map exists $attr->{$_} && !$ignore{$_} |
871 | map exists $attr->{$_} && !$ignore{$_} |
851 | ? [$_ => delete $attr->{$_}] : (), |
872 | ? [$_ => delete $attr->{$_}] : (), |
852 | @attr_order |
873 | @attr_order |
853 | ] |
874 | ] |
854 | }, |
875 | }, |
855 | |
|
|
856 | exists $section{$_} ? [$_ => delete $section{$_}] : (), |
876 | exists $section{$_} ? [$_ => delete $section{$_}] : (), |
857 | @section_order |
877 | @section_order |
858 | ]; |
878 | ]; |
859 | |
879 | |
860 | $attr |
880 | $attr |