--- deliantra/Deliantra-Client/DC/MapWidget.pm 2010/04/03 02:58:25 1.162 +++ deliantra/Deliantra-Client/DC/MapWidget.pm 2012/11/10 18:29:32 1.166 @@ -4,6 +4,8 @@ use List::Util qw(min max); +use AnyEvent (); + use DC; use DC::OpenGL; use DC::UI; @@ -433,7 +435,7 @@ if ($::CFG->{smooth_movement}) { if ($self->{sdx} || $self->{sdy}) { - my $diff = EV::time - ($self->{last_update} || $::LAST_REFRESH); + my $diff = AE::time - ($self->{last_update} || $::LAST_REFRESH); my $spd = $::CONN->{stat}{DC::Protocol::CS_STAT_SPEED}; # the minimum time for a single tile movement @@ -464,7 +466,7 @@ $self->{sdx} = $self->{sdy} = 0; } - $self->{last_update} = EV::time; + $self->{last_update} = AE::time; } sub refresh_hook { @@ -516,7 +518,7 @@ glTranslate DC::ceil $self->{sdx}, DC::ceil $self->{sdy}; $::MAP->draw ($dx, $dy, $sw, $sh, - $self->{tilesize}, + ($self->{tilesize}) x 2, $::CONN->{player}{tag}, -$self->{sdx}, -$self->{sdy}); @@ -613,7 +615,6 @@ our @ISA = DC::UI::Base::; -use Time::HiRes qw(time); use DC::OpenGL; sub size_request { @@ -623,7 +624,7 @@ sub refresh_hook { my ($self) = @_; - if ($::MAP && $self->{texture_atime} < time) { + if ($::MAP && $self->{texture_atime} < AE::now) { my ($w, $h) = @$self{qw(w h)}; return unless $w && $h; @@ -648,7 +649,7 @@ $self->{x0} = $x0; $self->{y0} = $y0; - $self->{texture_atime} = time + 1/3; + $self->{texture_atime} = AE::now + 1/2; $self->{texture} = new DC::Texture @@ -876,6 +877,8 @@ my ($cmd, $arg) = $text =~ /^\s*([^[:space:]]*)(.*)$/; + my $first_char = substr $cmd, 0, 1; + my $regexp_abbrev = do { my ($beg, @chr) = split //, lc $cmd; @@ -884,7 +887,7 @@ # - the more characters the parentheses match, the less attractive # is the match. my $regexp = "^\Q$beg\E" - . join "", map "(?:.*?[ \\\\]\Q$_\E|(.*?)\Q$_\E)", @chr; + . join "", map "(?:.*?[ _\-]|(.*?))\Q$_\E", @chr; qr<$regexp> }; @@ -894,6 +897,10 @@ }; for (keys %{$self->{command}}) { + # we only match and score if the first character matches, + # so quickly rule out all others first. + next unless $first_char = substr $_, 0, 1; + my @scores; # 1. Complete command [with args] @@ -902,7 +909,7 @@ # e.g. "invoke summon pet monster bat" # "invoke" "summon pet monster bat" = 6 # "invoke summon pet monster" "bat" = 25 - if ($text =~ /^\Q$_\E(.*)/) { + if ((substr $text, 0, length $_) eq $_) { push @scores, [$_, length $_, $text]; }