--- deliantra/Deliantra-Client/DC/Protocol.pm 2010/04/08 19:11:21 1.218 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2012/11/10 18:29:32 1.225 @@ -16,7 +16,7 @@ use base 'Deliantra::Protocol::Base'; our $TEX_DIALOGUE = new_from_resource DC::Texture - "dialogue.png", minify => 1, mipmap => 1; + "dialogue.png", minify => 1, mipmap => 1; our $TEX_NOFACE = new_from_resource DC::Texture "noface.png", minify => 1, mipmap => 1, wrap => 1; @@ -29,12 +29,46 @@ my $self = $class->SUPER::new (%arg, setup_req => { extmap => 1, - excmd => 1, widget => 2, %{$arg{setup_req} || {}}, }, ); + $self->update_fx_want; + + my $exp_guard = $self->addme_guard; + my $skl_guard = $self->addme_guard; + my $spl_guard = $self->addme_guard; + $self->send_exti_req (resource => qw(exp_table skill_info spell_paths), sub { + my ($exp, $skl, $spl) = @_; + + $self->register_face_handler ($exp, sub { + my ($face) = @_; + + undef $exp_guard; + $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data}); + $_->() for values %{ $self->{on_exp_update} }; + }); + + $self->register_face_handler ($skl, sub { + my ($face) = @_; + + undef $skl_guard; + my $info = $self->{json_coder}->decode (delete $face->{data}); + $self->{skill_info} = { map { CS_STAT_SKILLINFO + $_ => $info->[$_][0] } 0 .. $#$info }; + }); + + $self->register_face_handler ($spl, sub { + my ($face) = @_; + + undef $spl_guard; + my $info = $self->{json_coder}->decode (delete $face->{data}); + $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info }; + }); + + () + }); + $self->{map_widget}->clr_commands; my @cmd_help = map { @@ -97,7 +131,7 @@ } # $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id -# $self->{expire_w} = EV::timer 1, 1, sub { +# $self->{expire_w} = AE::timer 1, 1, sub { # my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1; # # for ($self->{map}->expire_textures ($self->{expire_count}, $count)) { @@ -119,6 +153,9 @@ $self } + #$self->send_exti_req (nickmon => 1, sub { use Data::Dump; ddx \@_ });#d# +#sub ext_nicklist { shift; use Data::Dump; ddx \@_; } #d# + sub update_fx_want { my ($self) = @_; @@ -132,21 +169,6 @@ sub ext_capabilities { my ($self, %cap) = @_; - $self->update_fx_want; - - $self->send_exti_req (resource => "exp_table", sub { - my ($exp_table) = @_; - - $self->register_face_handler ($exp_table, sub { - my ($face) = @_; - - $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data}); - $_->() for values %{ $self->{on_exp_update} || {} }; - }); - - () - }); - if (my $ts = $cap{tileset}) { if (my ($default) = grep $_->[2] & 1, @$ts) { $self->{tileset} = $default; @@ -456,7 +478,7 @@ ( ($stats->{+CS_STAT_EXP64} > $prev->{+CS_STAT_EXP64} ? ($stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) . " experience gained" : ()), map { - $stats->{$_} && $prev->{$_} + $stats->{$_} && $prev->{$_} && $stats->{$_}[1] > $prev->{$_}[1] ? "($self->{skill_info}{$_}+" . ($stats->{$_}[1] - $prev->{$_}[1]) . ")" : () } sort { $a <=> $b } keys %{$self->{skill_info}} ) @@ -671,7 +693,7 @@ sub feed_map1a { my ($self, $data) = @_; - my $missing = $self->{map}->map1a_update ($data, $self->{setup}{extmap}); + my $missing = $self->{map}->map1a_update ($data); my $delay; for my $tile (@$missing) { @@ -1044,7 +1066,7 @@ $prompt = $LAST_QUERY unless length $prompt; $LAST_QUERY = $prompt; - $self->{query}-> ($self, $flags, $prompt); + $self->{query}->($self, $flags, $prompt); } sub sanitise_xml($) { @@ -1086,8 +1108,8 @@ our @CF_COLOR = ( [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], - [1.00, 1.00, 1.00], - [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] + [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], + [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55], [1.00, 0.00, 0.00], [1.00, 0.54, 0.00], [0.11, 0.56, 1.00], @@ -1116,10 +1138,6 @@ my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0]; - ## try to create single paragraphs of multiple lines sent by the server - # no longer neecssary with TRT servers - #$text =~ s/(?<=\S)\n(?=\w)/ /g; - ::message ({ fg => $fg, markup => $text, @@ -1354,12 +1372,7 @@ $::SERVER_INFO->set_markup ( "server $self->{host}:$self->{port}\n" . "protocol version $version\n" - . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" - . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" - . "examine command support $yesno[$self->{setup}{excmd} > 0]\n" . "editing support $yesno[!!$self->{editor_support}]\n" - . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" - . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" . "client support $yesno[$self->{cfplus_ext} > 0]" . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" . "map size $self->{mapw}×$self->{maph}\n" @@ -1403,7 +1416,7 @@ if (exists $msg{npc_dialog}) { # start npc chat dialog - $self->{npc_dialog} = new DC::NPCDialog:: + $self->{w}{npc_dialog} = new DC::NPCDialog:: token => $msg{npc_dialog}, title => "$msg{npc_dialog}[0] (NPC)", conn => $self, @@ -1418,8 +1431,8 @@ sub destroy { my ($self) = @_; - (delete $self->{npc_dialog})->destroy - if $self->{npc_dialog}; + $_->destroy + for values %{ $self->{w} }; $self->SUPER::destroy; @@ -1583,7 +1596,7 @@ if ($self->{conn}) { $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id}; - delete $self->{conn}{npc_dialog}; + delete $self->{conn}{w}{npc_dialog}; $self->{conn}->disconnect_ext ($self->{id}); }