--- deliantra/Deliantra-Client/DC/Protocol.pm 2008/12/07 16:20:44 1.206 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2012/01/04 11:23:23 1.220 @@ -1,7 +1,8 @@ package DC::Protocol; -use utf8; -use strict; +use common::sense; + +use Guard (); use Deliantra::Protocol::Constants; @@ -18,7 +19,7 @@ "dialogue.png", minify => 1, mipmap => 1; our $TEX_NOFACE = new_from_resource DC::Texture - "noface.png", minify => 1, mipmap => 1; + "noface.png", minify => 1, mipmap => 1, wrap => 1; sub MIN_TEXTURE_UNUSED() { 1 }#d# @@ -96,7 +97,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)) { @@ -279,6 +280,9 @@ tooltip => $DC::UI::TOOLTIP, mapwidget => $::MAPWIDGET, + menubar => $::MENUBAR, + menupopup => $::MENUPOPUP, + pickup_enable => $::PICKUP_ENABLE, buttonbar => $::BUTTONBAR, metaserver => $::METASERVER, buttonbar => $::BUTTONBAR, @@ -305,7 +309,7 @@ help_window => $::HELP_WINDOW, message_window => $::MESSAGE_WINDOW, message_dist => $::MESSAGE_DIST, - statusbox => $::SDTATUSBOX, + statusbox => $::STATUSBOX, inv => $::INV, invr => $::INVR, @@ -399,7 +403,7 @@ } sort { $a <=> $b } keys %{$self->{spell_paths}}; - join "", @diff + "\u$name: " . (join ", ", @diff) } # all stats that are chacked against changes @@ -464,7 +468,7 @@ if ( my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange ) { - my $msg = "stat change: " . (join " ", @diffs); + my $msg = "stat change: " . (join " ", map "($_)", @diffs); $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20); } @@ -512,9 +516,9 @@ $::GAUGES->{mana} ->set_value ($sp, $sp_m); $::GAUGES->{food} ->set_value ($fo, $fo_m); $::GAUGES->{grace} ->set_value ($gr, $gr_m); - $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) - . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); - $::GAUGES->{prg} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); + $::GAUGES->{exp} ->set_label ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))#d# + . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); + $::GAUGES->{exp} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); my $title = $stats->{+CS_STAT_TITLE}; $title =~ s/^Player: //; @@ -536,7 +540,7 @@ $self->update_weight; - $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}}) + $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%%", $stats->{$RES_TBL{$_}}) for keys %RES_TBL; my $sktbl = $::STATWIDS->{skill_tbl}; @@ -637,8 +641,8 @@ $sw->[1]->set_text ($val->[0] * 1); $sw->[2]->set_value (@$val); - $::GAUGES->{sklprg}->set_label ("$name %d%%"); - $::GAUGES->{sklprg}->set_value (@$val); + $::GAUGES->{skillexp}->set_label ("$name %d%%"); + $::GAUGES->{skillexp}->set_value (@$val); } } @@ -987,7 +991,7 @@ new DC::Texture tile => $tile, image => $data, delete_image => 1, - minify => 1, mipmap => 1; + minify => 1; if (my $cbs = delete $self->{tile_cb}{$tile}) { $_->($tex) for @$cbs; @@ -1002,7 +1006,7 @@ push @{$self->{face_cb}{$num}}, $cb; defined wantarray - ? DC::guard { + ? Guard::guard { @{$self->{face_cb}{$num}} = grep $_ != $cb, @{$self->{face_cb}{$num}}; @@ -1040,7 +1044,7 @@ $prompt = $LAST_QUERY unless length $prompt; $LAST_QUERY = $prompt; - $self->{query}-> ($self, $flags, $prompt); + $self->{query}->($self, $flags, $prompt); } sub sanitise_xml($) { @@ -1112,10 +1116,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, @@ -1345,9 +1345,11 @@ my @yesno = ("no", "yes"); + my $version = JSON::XS->new->encode ($self->{s_version}); + $::SERVER_INFO->set_markup ( "server $self->{host}:$self->{port}\n" - . "protocol version $self->{version}\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" @@ -1385,10 +1387,7 @@ $self->update_server_info; $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; - $self->send_command ("pickup $::CFG->{pickup}"); - - $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]", - DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d# + $self->send_pickup ($::CFG->{pickup}); } sub lookat { @@ -1400,7 +1399,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, @@ -1415,8 +1414,8 @@ sub destroy { my ($self) = @_; - (delete $self->{npc_dialog})->destroy - if $self->{npc_dialog}; + $_->destroy + for values %{ $self->{w} }; $self->SUPER::destroy; @@ -1580,7 +1579,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}); }