ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.201 by root, Wed Sep 3 06:35:55 2008 UTC vs.
Revision 1.226 by root, Thu Nov 15 03:07:46 2012 UTC

1package DC::Protocol; 1package DC::Protocol;
2 2
3use utf8; 3use common::sense;
4use strict; 4
5use Guard ();
5 6
6use Deliantra::Protocol::Constants; 7use Deliantra::Protocol::Constants;
7 8
8use DC; 9use DC;
9use DC::DB; 10use DC::DB;
13use DC::Item; 14use DC::Item;
14 15
15use base 'Deliantra::Protocol::Base'; 16use base 'Deliantra::Protocol::Base';
16 17
17our $TEX_DIALOGUE = new_from_resource DC::Texture 18our $TEX_DIALOGUE = new_from_resource DC::Texture
18 "dialogue.png", minify => 1, mipmap => 1; 19 "dialogue.png", minify => 1, mipmap => 1;
19 20
20our $TEX_NOFACE = new_from_resource DC::Texture 21our $TEX_NOFACE = new_from_resource DC::Texture
21 "noface.png", minify => 1, mipmap => 1; 22 "noface.png", minify => 1, mipmap => 1, wrap => 1;
23
24sub MIN_TEXTURE_UNUSED() { 1 }#d#
22 25
23sub new { 26sub new {
24 my ($class, %arg) = @_; 27 my ($class, %arg) = @_;
25 28
26 my $self = $class->SUPER::new (%arg, 29 my $self = $class->SUPER::new (%arg,
27 setup_req => { 30 setup_req => {
28 extmap => 1, 31 extmap => 1,
29 excmd => 1,
30 widget => 2, 32 widget => 2,
31 %{$arg{setup_req} || {}}, 33 %{$arg{setup_req} || {}},
32 }, 34 },
33 ); 35 );
36
37 $self->update_fx_want;
38
39 my $exp_guard = $self->addme_guard;
40 my $skl_guard = $self->addme_guard;
41 my $spl_guard = $self->addme_guard;
42 my $cmd_guard = $self->addme_guard;
43 $self->send_exti_req (resource => qw(exp_table skill_info spell_paths command_list), sub {
44 my ($exp, $skl, $spl, $cmd) = @_;
45
46 $self->register_face_handler ($exp, sub {
47 my ($face) = @_;
48
49 undef $exp_guard;
50 $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data});
51 $_->() for values %{ $self->{on_exp_update} };
52 });
53
54 $self->register_face_handler ($skl, sub {
55 my ($face) = @_;
56
57 undef $skl_guard;
58 my $info = $self->{json_coder}->decode (delete $face->{data});
59 $self->{skill_info} = { map { CS_STAT_SKILLINFO + $_ => $info->[$_][0] } 0 .. $#$info };
60 });
61
62 $self->register_face_handler ($spl, sub {
63 my ($face) = @_;
64
65 undef $spl_guard;
66 my $info = $self->{json_coder}->decode (delete $face->{data});
67 $self->{spell_paths} = { map { (1 << $_) => $info->[$_][0] } 0 .. $#$info };
68 });
69
70 $self->register_face_handler ($cmd, sub {
71 my ($face) = @_;
72
73 undef $cmd_guard;
74 my $info = $self->{json_coder}->decode (delete $face->{data});
75 $self->{command_list} = [ sort map @{ $_->[1] }, grep $_->[0] != 2, @$info ];
76
77 });
78
79 ()
80 });
34 81
35 $self->{map_widget}->clr_commands; 82 $self->{map_widget}->clr_commands;
36 83
37 my @cmd_help = map { 84 my @cmd_help = map {
38 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 85 $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
73 for values %{delete $ws->{w} || {}}; 120 for values %{delete $ws->{w} || {}};
74 } 121 }
75 122
76 delete $self->{items}; 123 delete $self->{items};
77 $::INV->clear; 124 $::INV->clear;
125 $::INVR->clear;
78 $::INVR_HB->clear; 126 $::INVR_HB->clear;
79 $::FLOORBOX->clear; 127 $::FLOORBOX->clear;
80 }); 128 });
81 129
82 $self->{map_widget}->add_command (@$_) 130 $self->{map_widget}->add_command (@$_)
90 { 138 {
91 $self->{noface} = my $tex = $TEX_NOFACE; 139 $self->{noface} = my $tex = $TEX_NOFACE;
92 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 140 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
93 } 141 }
94 142
143# $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id
144# $self->{expire_w} = AE::timer 1, 1, sub {
145# my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1;
146#
147# for ($self->{map}->expire_textures ($self->{expire_count}, $count)) {
148# warn DC::SvREFCNT $self->{texture}[$_];
149# $self->{texture}[$_]->unload;
150# warn "expire texture $_\n";#d#
151# }
152#
153# ($self->{expire_count} += $count) < @{ $self->{texture} }
154# or $self->{expire_count} = DC::DB::FIRST_TILE_ID;
155# warn "count is $count\n";#d#
156# };
157
95 $self->{open_container} = 0; 158 $self->{open_container} = 0;
96 159
97 # per server 160 # per server
98 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; 161 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
99 162
100 $self 163 $self
101} 164}
165
166 #$self->send_exti_req (nickmon => 1, sub { use Data::Dump; ddx \@_ });#d#
167#sub ext_nicklist { shift; use Data::Dump; ddx \@_; } #d#
102 168
103sub update_fx_want { 169sub update_fx_want {
104 my ($self) = @_; 170 my ($self) = @_;
105 171
106 $self->send_exti_msg (fx_want => { 172 $self->send_exti_msg (fx_want => {
110 }); 176 });
111} 177}
112 178
113sub ext_capabilities { 179sub ext_capabilities {
114 my ($self, %cap) = @_; 180 my ($self, %cap) = @_;
115
116 $self->update_fx_want;
117
118 $self->send_exti_req (resource => "exp_table", sub {
119 my ($exp_table) = @_;
120
121 $self->register_face_handler ($exp_table, sub {
122 my ($face) = @_;
123
124 $self->{exp_table} = $self->{json_coder}->decode (delete $face->{data});
125 $_->() for values %{ $self->{on_exp_update} || {} };
126 });
127
128 ()
129 });
130 181
131 if (my $ts = $cap{tileset}) { 182 if (my $ts = $cap{tileset}) {
132 if (my ($default) = grep $_->[2] & 1, @$ts) { 183 if (my ($default) = grep $_->[2] & 1, @$ts) {
133 $self->{tileset} = $default; 184 $self->{tileset} = $default;
134 $self->{tilesize} = $default->[3]; 185 $self->{tilesize} = $default->[3];
259 my %wkw = ( 310 my %wkw = (
260 root => $DC::UI::ROOT, 311 root => $DC::UI::ROOT,
261 tooltip => $DC::UI::TOOLTIP, 312 tooltip => $DC::UI::TOOLTIP,
262 313
263 mapwidget => $::MAPWIDGET, 314 mapwidget => $::MAPWIDGET,
315 menubar => $::MENUBAR,
316 menupopup => $::MENUPOPUP,
317 pickup_enable => $::PICKUP_ENABLE,
264 buttonbar => $::BUTTONBAR, 318 buttonbar => $::BUTTONBAR,
265 metaserver => $::METASERVER, 319 metaserver => $::METASERVER,
266 buttonbar => $::BUTTONBAR, 320 buttonbar => $::BUTTONBAR,
267 login_button => $::LOGIN_BUTTON, 321 login_button => $::LOGIN_BUTTON,
268 quit_dialog => $::QUIT_DIALOG, 322 quit_dialog => $::QUIT_DIALOG,
285 339
286 floorbox => $::FLOORBOX, 340 floorbox => $::FLOORBOX,
287 help_window => $::HELP_WINDOW, 341 help_window => $::HELP_WINDOW,
288 message_window => $::MESSAGE_WINDOW, 342 message_window => $::MESSAGE_WINDOW,
289 message_dist => $::MESSAGE_DIST, 343 message_dist => $::MESSAGE_DIST,
290 statusbox => $::SDTATUSBOX, 344 statusbox => $::STATUSBOX,
291 345
292 inv => $::INV, 346 inv => $::INV,
293 invr => $::INVR, 347 invr => $::INVR,
294 invr_hb => $::INVR_HB, 348 invr_hb => $::INVR_HB,
295 ); 349 );
379 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_}) 433 ? (($new & $_ ? "+" : "-") . $self->{spell_paths}{$_})
380 : () 434 : ()
381 } 435 }
382 sort { $a <=> $b } keys %{$self->{spell_paths}}; 436 sort { $a <=> $b } keys %{$self->{spell_paths}};
383 437
384 join "", @diff 438 "\u$name: " . (join ", ", @diff)
385} 439}
386 440
387# all stats that are chacked against changes 441# all stats that are chacked against changes
388my @statchange = ( 442my @statchange = (
389 [&CS_STAT_STR => \&_stat_numdiff, "Str"], 443 [&CS_STAT_STR => \&_stat_numdiff, "Str"],
432 486
433 if (my @diffs = 487 if (my @diffs =
434 ( 488 (
435 ($stats->{+CS_STAT_EXP64} > $prev->{+CS_STAT_EXP64} ? ($stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) . " experience gained" : ()), 489 ($stats->{+CS_STAT_EXP64} > $prev->{+CS_STAT_EXP64} ? ($stats->{+CS_STAT_EXP64} - $prev->{+CS_STAT_EXP64}) . " experience gained" : ()),
436 map { 490 map {
437 $stats->{$_} && $prev->{$_} 491 $stats->{$_} && $prev->{$_}
438 && $stats->{$_}[1] > $prev->{$_}[1] ? "($self->{skill_info}{$_}+" . ($stats->{$_}[1] - $prev->{$_}[1]) . ")" : () 492 && $stats->{$_}[1] > $prev->{$_}[1] ? "($self->{skill_info}{$_}+" . ($stats->{$_}[1] - $prev->{$_}[1]) . ")" : ()
439 } sort { $a <=> $b } keys %{$self->{skill_info}} 493 } sort { $a <=> $b } keys %{$self->{skill_info}}
440 ) 494 )
441 ) { 495 ) {
442 my $msg = join " ", @diffs; 496 my $msg = join " ", @diffs;
444 } 498 }
445 499
446 if ( 500 if (
447 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange 501 my @diffs = map $_->[1]->($self, $_->[2], $prev->{$_->[0]}, $stats->{$_->[0]}), @statchange
448 ) { 502 ) {
449 my $msg = "<b>stat change</b>: " . (join " ", @diffs); 503 my $msg = "<b>stat change</b>: " . (join " ", map "($_)", @diffs);
450 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20); 504 $self->{statusbox}->add ($msg, group => "stat $msg", fg => [0.8, 1, 0.2, 1], timeout => 20);
451 } 505 }
452 506
453 $self->update_stats_window ($stats, $prev); 507 $self->update_stats_window ($stats, $prev);
454 508
492 546
493 $::GAUGES->{hp} ->set_value ($hp, $hp_m); 547 $::GAUGES->{hp} ->set_value ($hp, $hp_m);
494 $::GAUGES->{mana} ->set_value ($sp, $sp_m); 548 $::GAUGES->{mana} ->set_value ($sp, $sp_m);
495 $::GAUGES->{food} ->set_value ($fo, $fo_m); 549 $::GAUGES->{food} ->set_value ($fo, $fo_m);
496 $::GAUGES->{grace} ->set_value ($gr, $gr_m); 550 $::GAUGES->{grace} ->set_value ($gr, $gr_m);
497 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) 551 $::GAUGES->{exp} ->set_label ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))#d#
498 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); 552 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
499 $::GAUGES->{prg} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64}); 553 $::GAUGES->{exp} ->set_value ($stats->{+CS_STAT_LEVEL}, $stats->{+CS_STAT_EXP64});
500 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE}); 554 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE});
501 my $title = $stats->{+CS_STAT_TITLE}; 555 my $title = $stats->{+CS_STAT_TITLE};
502 $title =~ s/^Player: //; 556 $title =~ s/^Player: //;
503 $::STATWIDS->{title} ->set_text ("Title: " . $title); 557 $::STATWIDS->{title} ->set_text ("Title: " . $title);
504 558
516 $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED}); 570 $::STATWIDS->{st_spd} ->set_text (sprintf "%.1f", $stats->{+CS_STAT_SPEED});
517 $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP}); 571 $::STATWIDS->{st_wspd}->set_text (sprintf "%.1f", $stats->{+CS_STAT_WEAP_SP});
518 572
519 $self->update_weight; 573 $self->update_weight;
520 574
521 $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%", $stats->{$RES_TBL{$_}}) 575 $::STATWIDS->{"res_$_"}->set_text (sprintf "%d%%", $stats->{$RES_TBL{$_}})
522 for keys %RES_TBL; 576 for keys %RES_TBL;
523 577
524 my $sktbl = $::STATWIDS->{skill_tbl}; 578 my $sktbl = $::STATWIDS->{skill_tbl};
525 my @skills = keys %{ $self->{skill_info} }; 579 my @skills = keys %{ $self->{skill_info} };
526 580
545 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0), 599 7, 0, (new DC::UI::Label text => "Skill", expand => 1, align => 0),
546 ]; 600 ];
547 601
548 my @add = @$sw; 602 my @add = @$sw;
549 603
550 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use spell\nRight click - further options</small>"; 604 my $TOOLTIP_ALL = "\n\n<small>Left click - ready skill\nMiddle click - use skill\nRight click - further options</small>";
551 605
552 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 606 my @TOOLTIP_LVL = (tooltip => "<b>Level</b>. The level of the skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
553 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1); 607 my @TOOLTIP_EXP = (tooltip => "<b>Experience</b>. The experience points you have in this skill.$TOOLTIP_ALL", can_events => 1, can_hover => 1);
554 608
555 my ($x, $y) = (0, 1); 609 my ($x, $y) = (0, 1);
617 my $sw = $self->{skillwid}{$idx}; 671 my $sw = $self->{skillwid}{$idx};
618 $sw->[0]->set_text (::formsep ($val->[1])); 672 $sw->[0]->set_text (::formsep ($val->[1]));
619 $sw->[1]->set_text ($val->[0] * 1); 673 $sw->[1]->set_text ($val->[0] * 1);
620 $sw->[2]->set_value (@$val); 674 $sw->[2]->set_value (@$val);
621 675
622 $::GAUGES->{sklprg}->set_label ("$name %d%%"); 676 $::GAUGES->{skillexp}->set_label ("$name %d%%");
623 $::GAUGES->{sklprg}->set_value (@$val); 677 $::GAUGES->{skillexp}->set_value (@$val);
624 } 678 }
625} 679}
626 680
627sub user_send { 681sub user_send {
628 my ($self, $command) = @_; 682 my ($self, $command) = @_;
647} 701}
648 702
649sub feed_map1a { 703sub feed_map1a {
650 my ($self, $data) = @_; 704 my ($self, $data) = @_;
651 705
652 my $missing = $self->{map}->map1a_update ($data, $self->{setup}{extmap}); 706 my $missing = $self->{map}->map1a_update ($data);
653 my $delay; 707 my $delay;
654 708
655 for my $tile (@$missing) { 709 for my $tile (@$missing) {
656 next if $self->{delay}{$tile}; 710 next if $self->{delay}{$tile};
657 711
658 $delay = 1; 712 $delay = 1;
659 713
660 if (my $tex = $::CONN->{texture}[$tile]) { 714 if (my $tex = $self->{texture}[$tile]) {
661 $tex->upload; 715 $tex->upload;
662 } else { 716 } else {
663 $self->{delay}{$tile} = 1; 717 $self->{delay}{$tile} = 1;
664 718
665 # we assume the face is in-flight and will eventually come 719 # we assume the face is in-flight and will eventually arrive
666 push @{$self->{tile_cb}{$tile}}, sub { 720 push @{$self->{tile_cb}{$tile}}, sub {
667 delete $self->{delay}{$tile}; 721 delete $self->{delay}{$tile};
668 $_[0]->upload; 722 $_[0]->upload;
669 }; 723 };
670 } 724 }
671 } 725 }
672 726
673 if ($delay) { 727 if ($delay) {
674 # delay the map drawing a tiny bit in the hope of getting the missing fetched 728 # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched
675 EV::once undef, 0, 0.03, sub { 729 EV::once undef, 0, 0.03, sub {
676 $self->{map_widget}->update 730 $self->{map_widget}->update
677 if $self->{map_widget}; 731 if $self->{map_widget};
678 }; 732 };
679 } else { 733 } else {
967 1021
968 my $tex = $self->{texture}[$tile] ||= 1022 my $tex = $self->{texture}[$tile] ||=
969 new DC::Texture 1023 new DC::Texture
970 tile => $tile, 1024 tile => $tile,
971 image => $data, delete_image => 1, 1025 image => $data, delete_image => 1,
972 minify => 1, mipmap => 1; 1026 minify => 1;
973 1027
974 if (my $cbs = delete $self->{tile_cb}{$tile}) { 1028 if (my $cbs = delete $self->{tile_cb}{$tile}) {
975 $_->($tex) for @$cbs; 1029 $_->($tex) for @$cbs;
976 } 1030 }
977} 1031}
982 my ($self, $num, $cb) = @_; 1036 my ($self, $num, $cb) = @_;
983 1037
984 push @{$self->{face_cb}{$num}}, $cb; 1038 push @{$self->{face_cb}{$num}}, $cb;
985 1039
986 defined wantarray 1040 defined wantarray
987 ? DC::guard { 1041 ? Guard::guard {
988 @{$self->{face_cb}{$num}} 1042 @{$self->{face_cb}{$num}}
989 = grep $_ != $cb, 1043 = grep $_ != $cb,
990 @{$self->{face_cb}{$num}}; 1044 @{$self->{face_cb}{$num}};
991 } 1045 }
992 : () 1046 : ()
1020 my ($self, $flags, $prompt) = @_; 1074 my ($self, $flags, $prompt) = @_;
1021 1075
1022 $prompt = $LAST_QUERY unless length $prompt; 1076 $prompt = $LAST_QUERY unless length $prompt;
1023 $LAST_QUERY = $prompt; 1077 $LAST_QUERY = $prompt;
1024 1078
1025 $self->{query}-> ($self, $flags, $prompt); 1079 $self->{query}->($self, $flags, $prompt);
1026} 1080}
1027 1081
1028sub sanitise_xml($) { 1082sub sanitise_xml($) {
1029 local $_ = shift; 1083 local $_ = shift;
1030 1084
1062 tan => 12, 1116 tan => 12,
1063); 1117);
1064 1118
1065our @CF_COLOR = ( 1119our @CF_COLOR = (
1066 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 1120 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
1067 [1.00, 1.00, 1.00], 1121 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
1068 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 1122 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55],
1069 [1.00, 0.00, 0.00], 1123 [1.00, 0.00, 0.00],
1070 [1.00, 0.54, 0.00], 1124 [1.00, 0.54, 0.00],
1071 [0.11, 0.56, 1.00], 1125 [0.11, 0.56, 1.00],
1072 [0.93, 0.46, 0.00], 1126 [0.93, 0.46, 0.00],
1073 [0.18, 0.54, 0.34], 1127 [0.18, 0.54, 0.34],
1092 $self->logprint ("msg: ", $text); 1146 $self->logprint ("msg: ", $text);
1093 return if $color < 0; # negative color == ignore if not understood 1147 return if $color < 0; # negative color == ignore if not understood
1094 1148
1095 my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0]; 1149 my $fg = $CF_COLOR[$color & NDI_COLOR_MASK] || [1, 0, 0];
1096 1150
1097 ## try to create single paragraphs of multiple lines sent by the server
1098 # no longer neecssary with TRT servers
1099 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
1100
1101 for (split /\n/, $text) {
1102 ::message ({ 1151 ::message ({
1103 fg => $fg, 1152 fg => $fg,
1104 markup => $_, 1153 markup => $text,
1105 type => $type, 1154 type => $type,
1106 extra => [@extra], 1155 extra => [@extra],
1107 color_flags => $color, #d# ugly, kill 1156 color_flags => $color, #d# ugly, kill
1108 }); 1157 });
1109 1158
1110 $color &= ~NDI_CLEAR; # only clear once for multiline messages 1159# $color &= ~NDI_CLEAR; # only clear once for multiline messages
1111 # actually, this is an ugly design. _we_ should control the channels, 1160# # actually, this is an ugly design. _we_ should control the channels,
1112 # not some random other widget, as the channels are clearly protocol-specific. 1161# # not some random other widget, as the channels are clearly protocol-specific.
1113 # then we could also react to flags such as CLEAR without resorting to 1162# # then we could also react to flags such as CLEAR without resorting to
1114 # hacks such as color_flags, above. 1163# # hacks such as color_flags, above.
1115 }
1116 1164
1117 $self->{statusbox}->add ($text, 1165 $self->{statusbox}->add ($text,
1118 group => $text, 1166 group => $text,
1119 fg => $fg, 1167 fg => $fg,
1120 timeout => $color >= 2 ? 180 : 10, 1168 timeout => $color >= 2 ? 180 : 10,
1327sub update_server_info { 1375sub update_server_info {
1328 my ($self) = @_; 1376 my ($self) = @_;
1329 1377
1330 my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>"); 1378 my @yesno = ("<span foreground='red'>no</span>", "<span foreground='green'>yes</span>");
1331 1379
1380 my $version = JSON::XS->new->encode ($self->{s_version});
1381
1332 $::SERVER_INFO->set_markup ( 1382 $::SERVER_INFO->set_markup (
1333 "server <tt>$self->{host}:$self->{port}</tt>\n" 1383 "server <tt>$self->{host}:$self->{port}</tt>\n"
1334 . "protocol version <tt>$self->{version}</tt>\n" 1384 . "protocol version <tt>$version</tt>\n"
1335 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
1336 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
1337 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
1338 . "editing support $yesno[!!$self->{editor_support}]\n" 1385 . "editing support $yesno[!!$self->{editor_support}]\n"
1339 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
1340 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
1341 . "client support $yesno[$self->{cfplus_ext} > 0]" 1386 . "client support $yesno[$self->{cfplus_ext} > 0]"
1342 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 1387 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
1343 . "map size $self->{mapw}×$self->{maph}\n" 1388 . "map size $self->{mapw}×$self->{maph}\n"
1344 ); 1389 );
1345 1390
1367 }); 1412 });
1368 1413
1369 $self->update_server_info; 1414 $self->update_server_info;
1370 1415
1371 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; 1416 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
1372 $self->send_command ("pickup $::CFG->{pickup}"); 1417 $self->send_pickup ($::CFG->{pickup});
1373
1374 $self->send_exti_msg (clientlog => sprintf "OpenGL Info: %s [%s]",
1375 DC::OpenGL::gl_vendor, DC::OpenGL::gl_version);#d#
1376} 1418}
1377 1419
1378sub lookat { 1420sub lookat {
1379 my ($self, $x, $y) = @_; 1421 my ($self, $x, $y) = @_;
1380 1422
1382 $self->send_ext_req (lookat => $x, $y, sub { 1424 $self->send_ext_req (lookat => $x, $y, sub {
1383 my (%msg) = @_; 1425 my (%msg) = @_;
1384 1426
1385 if (exists $msg{npc_dialog}) { 1427 if (exists $msg{npc_dialog}) {
1386 # start npc chat dialog 1428 # start npc chat dialog
1387 $self->{npc_dialog} = new DC::NPCDialog:: 1429 $self->{w}{npc_dialog} = new DC::NPCDialog::
1388 token => $msg{npc_dialog}, 1430 token => $msg{npc_dialog},
1389 title => "$msg{npc_dialog}[0] (NPC)", 1431 title => "$msg{npc_dialog}[0] (NPC)",
1390 conn => $self, 1432 conn => $self,
1391 ; 1433 ;
1392 } 1434 }
1397} 1439}
1398 1440
1399sub destroy { 1441sub destroy {
1400 my ($self) = @_; 1442 my ($self) = @_;
1401 1443
1402 (delete $self->{npc_dialog})->destroy 1444 $_->destroy
1403 if $self->{npc_dialog}; 1445 for values %{ $self->{w} };
1404 1446
1405 $self->SUPER::destroy; 1447 $self->SUPER::destroy;
1406 1448
1407 %$self = (); 1449 %$self = ();
1408} 1450}
1544} 1586}
1545 1587
1546sub send { 1588sub send {
1547 my ($self, $msg) = @_; 1589 my ($self, $msg) = @_;
1548 1590
1549 $self->{textview}->add_paragraph ({ markup => "\n" . DC::asxml $msg }); 1591 $self->{textview}->add_paragraph ({
1592 markup =>
1593 "\n<span foreground='#ffff00'><b>"
1594 . (DC::asxml $msg)
1595 . "</b></span>"
1596 });
1550 $self->{textview}->scroll_to_bottom; 1597 $self->{textview}->scroll_to_bottom;
1551 1598
1552 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg); 1599 $self->{conn}->send_ext_msg (npc_dialog_tell => $self->{id}, $msg);
1553} 1600}
1554 1601
1557 1604
1558 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1 1605 #Carp::cluck "debug\n";#d# #todo# enable: destroy gets called twice because scalar keys {} is 1
1559 1606
1560 if ($self->{conn}) { 1607 if ($self->{conn}) {
1561 $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id}; 1608 $self->{conn}->send_ext_msg (npc_dialog_end => $self->{id}) if $self->{id};
1562 delete $self->{conn}{npc_dialog}; 1609 delete $self->{conn}{w}{npc_dialog};
1563 $self->{conn}->disconnect_ext ($self->{id}); 1610 $self->{conn}->disconnect_ext ($self->{id});
1564 } 1611 }
1565 1612
1566 $self->SUPER::destroy; 1613 $self->SUPER::destroy;
1567} 1614}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines