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.94 by root, Fri Mar 16 02:33:49 2007 UTC vs.
Revision 1.111 by root, Mon Jul 2 02:58:51 2007 UTC

4use strict; 4use strict;
5 5
6use Crossfire::Protocol::Constants; 6use Crossfire::Protocol::Constants;
7 7
8use CFPlus; 8use CFPlus;
9use CFPlus::DB;
9use CFPlus::UI; 10use CFPlus::UI;
10use CFPlus::Pod; 11use CFPlus::Pod;
11use CFPlus::Macro; 12use CFPlus::Macro;
12use CFPlus::Item; 13use CFPlus::Item;
13 14
14use Crossfire::Protocol::Base 0.95; 15use Crossfire::Protocol::Base 0.95;
15 16
16use base 'Crossfire::Protocol::Base'; 17use base 'Crossfire::Protocol::Base';
17 18
18sub new { 19sub new {
19 my $class = shift; 20 my ($class, %arg) = @_;
20 21
21 my $self = $class->SUPER::new (@_, setup_req => { extmap => 1 }); 22 my $self = $class->SUPER::new (%arg,
23 setup_req => {
24 extmap => 1,
25 excmd => 1,
26 xwidget => 1,
27 %{$arg{setup_req} || {}},
28 },
29 );
22 30
23 $self->{map_widget}->clr_commands; 31 $self->{map_widget}->clr_commands;
24 32
25 my @cmd_help = map { 33 my @cmd_help = map {
26 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 34 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
37 for @args; 45 for @args;
38 46
39 map ["$cmd$_", $text], 47 map ["$cmd$_", $text],
40 sort { (length $a) <=> (length $b) } 48 sort { (length $a) <=> (length $b) }
41 @args 49 @args
42 } sort { $a->{par} <=> $b->{par} } 50 } sort { $a->{par} <=> $b->{par} }
43 CFPlus::Pod::find command => "*"; 51 CFPlus::Pod::find command => "*";
44 52
53 $self->connect_ext (event_capabilities => sub {
54 my ($cap) = @_;
55
56 if (my $ts = $cap->{tileset}) {
57 if (my ($default) = grep $_->[2] & 1, @$ts) {
58 $self->{tileset} = $default;
59 $self->{tilesize} = $default->[3];
60 $self->setup_req (tileset => $default->[0]);
61
62 my $w = int $self->{mapw} * 32 / $self->{tilesize};
63 my $h = int $self->{maph} * 32 / $self->{tilesize};
64
65 $self->setup_req (mapsize => "${w}x${h}");
66 }
67 }
68 });
69
70 $self->{json_coder}
71 ->convert_blessed
72 ->filter_json_single_key_object (__widget_ref__ => sub {
73 $self->{widget}{$_[0]}
74 });
75
76 $self->connect_ext (ws_n => sub {
77 my ($arg) = @_;
78
79 $self->{widgetset}{$arg{id}} = {
80 w => {},
81 };
82 });
83
84 $self->connect_ext (ws_d => sub {
85 my ($arg) = @_;
86
87 my $ws = delete $self->{widgetset}{$arg{id}}
88 or return;
89
90 $_->destroy
91 for values %{$ws->{w}};
92 });
93
94 $self->connect_ext (ws_c => sub {
95 my ($arg) = @_;
96
97 my $args = $arg->{args} || {};
98
99 for my $ev (grep /^on_/, keys %$args) {
100 $args->{$ev} = sub {
101 my $id = shift->{s_id};
102 $self->send_exti_msg (w_e => id => $id, name => $ev, args => \@_);
103
104 1
105 };
106 }
107
108 if (my $widget = eval {
109 local $SIG{__DIE__};
110 "CFPlus::UI::$arg->{class}"->new (
111 %$args,
112 s_ws => $arg->{ws},
113 s_id => $arg->{id},
114 )
115 }
116 ) {
117 $self->{widget}{$arg->{id}}
118 = $self->{widgetset}{$arg->{ws}}{w}{$arg->{id}}
119 = $widget;
120
121 $widget->connect (on_destroy => sub {
122 my ($widget) = @_;
123
124 delete $self->{widget}{$widget->{s_id}};
125 delete $self->{widgetset}{$widget->{s_ws}}{$widget->{s_id}};
126 });
127 } else {
128 warn "server failed creating client-side widget " . (CFPlus::to_json $arg) . ": $@\n";
129 $self->send_exti_msg (w_e => id => $arg->{id}, name => "destroy");
130 }
131 });
132
133 $self->connect_ext (w_c => sub {
134 my ($arg) = @_;
135
136 my $w = $self->{widget}{$arg->{id}}
137 or return;
138 my $m = $arg->{name};
139
140 my $a = $arg->{args} || [];
141
142 if (exists $arg->{rid}) {
143 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [$w->$m (@$a)]);
144 } else {
145 $w->$m (@$a);
146 }
147 });
148
149 $self->connect_ext (w_s => sub {
150 my ($arg) = @_;
151
152 my $w = $self->{widget}{$arg->{id}}
153 or return;
154
155 $w->{$arg->{name}} = $arg->{value};
156 });
157
158 $self->connect_ext (w_g => sub {
159 my ($arg) = @_;
160
161 my $w = $self->{widget}{$arg->{id}}
162 or return;
163
164 $self->send_exti_msg (w_r => rid => $arg->{rid}, res => [$w->{$arg->{name}}]);
165 });
166
167 $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub {
168 for my $ws (values %{delete $self->{widgetset} || {}}) {
169 $_->destroy
170 for values %{delete $ws->{w} || {}};
171 }
172 });
173
45 $self->{map_widget}->add_command (@$_) 174 $self->{map_widget}->add_command (@$_)
46 for @cmd_help; 175 for @cmd_help;
47
48 $self->{noface} = new_from_file CFPlus::Texture
49 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1;
50 176
51 { 177 {
52 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture 178 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture
53 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; 179 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
54 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 180 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
55 } 181 }
56 182
183 {
184 $self->{noface} = my $tex = new_from_file CFPlus::Texture
185 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1;
186 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
187 }
188
57 $self->{open_container} = 0; 189 $self->{open_container} = 0;
58 190
59 # "global"
60 $self->{tilecache} = CFPlus::db_table "tilecache"
61 or die "tilecache: unable to open database table";
62 $self->{facemap} = CFPlus::db_table "facemap"
63 or die "facemap: unable to open database table";
64
65 # per server 191 # per server
66 $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}" 192 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
67 or die "mapcache_$self->{host}_$self->{port}: unable to open database table";
68 193
69 $self 194 $self
70} 195}
71 196
72sub logprint { 197sub logprint {
229 $::GAUGES->{mana} ->set_value ($sp, $sp_m); 354 $::GAUGES->{mana} ->set_value ($sp, $sp_m);
230 $::GAUGES->{food} ->set_value ($fo, $fo_m); 355 $::GAUGES->{food} ->set_value ($fo, $fo_m);
231 $::GAUGES->{grace} ->set_value ($gr, $gr_m); 356 $::GAUGES->{grace} ->set_value ($gr, $gr_m);
232 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) 357 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))
233 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); 358 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
234 my $rng = $stats->{+CS_STAT_RANGE}; 359 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE});
235 $rng =~ s/^Range: //; # thank you so much dear server
236 $::GAUGES->{range} ->set_text ("Rng: " . $rng);
237 my $title = $stats->{+CS_STAT_TITLE}; 360 my $title = $stats->{+CS_STAT_TITLE};
238 $title =~ s/^Player: //; 361 $title =~ s/^Player: //;
239 $::STATWIDS->{title} ->set_text ("Title: " . $title); 362 $::STATWIDS->{title} ->set_text ("Title: " . $title);
240 363
241 $::STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR}); 364 $::STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR});
374 or return; 497 or return;
375 498
376 my ($hash, $x, $y, $w, $h) = @$map_info; 499 my ($hash, $x, $y, $w, $h) = @$map_info;
377 500
378 my $data = $self->{map}->get_rect ($x, $y, $w, $h); 501 my $data = $self->{map}->get_rect ($x, $y, $w, $h);
379 $self->{mapcache}->put ($hash => Compress::LZF::compress $data); 502 CFPlus::DB::put $self->{mapcache} => $hash => Compress::LZF::compress $data, sub { };
380 #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# 503 #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d#
381} 504}
382 505
383sub map_clear { 506sub map_clear {
384 my ($self) = @_; 507 my ($self) = @_;
388 511
389 $self->{map}->clear; 512 $self->{map}->clear;
390 delete $self->{map_widget}{magicmap}; 513 delete $self->{map_widget}{magicmap};
391} 514}
392 515
516sub bg_fetch {
517 my ($self) = @_;
518
519 my $id;
520
521 do {
522 $id = pop @{$self->{bg_fetch}}
523 or return;
524 } while $self->{texture}[$id];
525
526 CFPlus::DB::get tilecache => $id, sub {
527 my ($data) = @_;
528
529 return unless $self->{map}; # stop when destroyed
530
531 $self->set_texture ($id => $data)
532 if defined $data;
533
534 $self->bg_fetch;
535 };
536}
393 537
394sub load_map($$$) { 538sub load_map($$$) {
395 my ($self, $hash, $x, $y) = @_; 539 my ($self, $hash, $x, $y) = @_;
396 540
397 if (defined (my $data = $self->{mapcache}->get ($hash))) { 541 my $gen = $self->{map_change_gen};
542
543 CFPlus::DB::get $self->{mapcache} => $hash, sub {
544 return unless $gen == $self->{map_change_gen};
545
546 my ($data) = @_;
547
548 if (defined $data) {
398 $data = Compress::LZF::decompress $data; 549 $data = Compress::LZF::decompress $data;
399 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# 550 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d#
400 for my $id ($self->{map}->set_rect ($x, $y, $data)) {
401 my $data = $self->{tilecache}->get ($id)
402 or next;
403 551
404 $self->set_texture ($id => $data); 552 my $inprogress = @{ $self->{bg_fetch} || [] };
553 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data);
554 $self->bg_fetch unless $inprogress;
405 } 555 }
406 } 556 };
407} 557}
408 558
409# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 559# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
410# (server resource,s latency, bandwidth), so this hack is warranted. 560# (server resource,s latency, bandwidth), so this hack is warranted.
411# the right fix is to make real tiled maps with an overview file 561# the right fix is to make real tiled maps with an overview file
475 625
476 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 626 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
477 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 627 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
478 628
479 } else { 629 } else {
630 my $gen = $self->{map_change_gen};
480 $self->send_mapinfo ("spatial $path$tile", sub { 631 $self->send_mapinfo ("spatial $path$tile", sub {
632 return unless $gen == $self->{map_change_gen};
633
481 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 634 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
482 635
483 return if $mode ne "spatial"; 636 return if $mode ne "spatial";
484 637
485 $x += $self->{map}->ox; 638 $x += $self->{map}->ox;
499 652
500sub map_change { 653sub map_change {
501 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 654 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
502 655
503 $self->flush_map; 656 $self->flush_map;
657
658 ++$self->{map_change_gen};
504 659
505 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 660 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
506 661
507 my $mapmapw = $self->{mapmap}->{w}; 662 my $mapmapw = $self->{mapmap}->{w};
508 my $mapmaph = $self->{mapmap}->{h}; 663 my $mapmaph = $self->{mapmap}->{h};
525 $self->load_map ($hash, $x, $y); 680 $self->load_map ($hash, $x, $y);
526 $self->flood_fill (0, 0, 0, "", $hash, $flags); 681 $self->flood_fill (0, 0, 0, "", $hash, $flags);
527} 682}
528 683
529sub face_find { 684sub face_find {
530 my ($self, $facenum, $face) = @_; 685 my ($self, $facenum, $face, $cb) = @_;
531 686
532 my $hash = "$face->{chksum},$face->{name}"; 687 my $hash = "$face->{chksum},$face->{name}";
533 688
534 my $id = $self->{facemap}->get ($hash); 689 my $id = CFPlus::DB::get_tile_id_sync $hash;
535 690
536 unless ($id) {
537 # create new id for face
538 # I love transactions
539 for (1..100) {
540 my $txn = $CFPlus::DB_ENV->txn_begin;
541 my $status = $self->{facemap}->db_get (id => $id);
542 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) {
543 $id = ($id || 64) + 1;
544 if ($self->{facemap}->put (id => $id) == 0
545 && $self->{facemap}->put ($hash => $id) == 0) {
546 $txn->txn_commit;
547
548 goto gotid;
549 }
550 }
551 $txn->txn_abort;
552 }
553
554 CFPlus::fatal "maximum number of transaction retries reached - database problems?";
555 }
556
557gotid:
558 $face->{id} = $id; 691 $face->{id} = $id;
559 $self->{map}->set_face ($facenum => $id);
560 $self->{faceid}[$facenum] = $id;#d# 692 $self->{faceid}[$facenum] = $id;
561 693
562 my $face = $self->{tilecache}->get ($id); 694 $self->{map}->set_tileid ($facenum => $id);
563 695
564 if ($face) { 696 CFPlus::DB::get tilecache => $id, $cb;
565 #$self->face_prefetch;
566 $face
567 } else {
568 my $tex = $self->{noface};
569 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
570 undef
571 };
572} 697}
573 698
574sub face_update { 699sub face_update {
575 my ($self, $facenum, $face, $changed) = @_; 700 my ($self, $facenum, $face, $changed) = @_;
576 701
577 $self->{tilecache}->put ($face->{id} => $face->{image}) if $changed; 702 CFPlus::DB::put tilecache => $face->{id} => $face->{image}, sub { }
703 if $changed;
578 704
579 $self->set_texture ($face->{id} => delete $face->{image}); 705 $self->set_texture ($face->{id} => delete $face->{image});
706}
707
708sub smooth_update {
709 my ($self, $facenum, $face) = @_;
710
711 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel});
580} 712}
581 713
582sub set_texture { 714sub set_texture {
583 my ($self, $id, $data) = @_; 715 my ($self, $id, $data) = @_;
584 716
585 $self->{texture}[$id] ||= do { 717 $self->{texture}[$id] = my $tex =
586 my $tex =
587 new_from_image CFPlus::Texture 718 new_from_image CFPlus::Texture
588 $data, minify => 1, mipmap => 1; 719 $data, minify => 1, mipmap => 1;
589 720
590 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 721 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
591 $self->{map_widget}->update; 722 $self->{map_widget}->update;
592
593 $tex
594 };
595} 723}
596 724
597sub sound_play { 725sub sound_play {
598 my ($self, $x, $y, $soundnum, $type) = @_; 726 my ($self, $x, $y, $soundnum, $type) = @_;
599 727
609 $LAST_QUERY = $prompt; 737 $LAST_QUERY = $prompt;
610 738
611 $self->{query}-> ($self, $flags, $prompt); 739 $self->{query}-> ($self, $flags, $prompt);
612} 740}
613 741
614sub drawinfo { 742sub sanitise_xml($) {
615 my ($self, $color, $text) = @_; 743 local $_ = shift;
616 744
617 my @color = ( 745 # we now weed out all tags we do not support
746 s%<(?!/?i>|/?u>|/?b>|fg |/fg>)%&lt;%g;
747 # now all entities
748 s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g;
749
750 # handle some elements
751 s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs;
752 s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs;
753
754 $_
755}
756
757our %NAME_TO_COLOR = (
758 black => 0,
759 white => 1,
760 darkblue => 2,
761 red => 3,
762 orange => 4,
763 lightblue => 5,
764 darkorange => 6,
765 green => 7,
766 darkgreen => 8,
767 grey => 9,
768 brown => 10,
769 yellow => 11,
770 tan => 12,
771);
772
773our @CF_COLOR = (
618 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 774 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
619 [1.00, 1.00, 1.00], 775 [1.00, 1.00, 1.00],
620 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 776 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
621 [1.00, 0.00, 0.00], 777 [1.00, 0.00, 0.00],
622 [1.00, 0.54, 0.00], 778 [1.00, 0.54, 0.00],
623 [0.11, 0.56, 1.00], 779 [0.11, 0.56, 1.00],
624 [0.93, 0.46, 0.00], 780 [0.93, 0.46, 0.00],
625 [0.18, 0.54, 0.34], 781 [0.18, 0.54, 0.34],
626 [0.56, 0.73, 0.56], 782 [0.56, 0.73, 0.56],
627 [0.80, 0.80, 0.80], 783 [0.80, 0.80, 0.80],
628 [0.75, 0.61, 0.20], 784 [0.75, 0.61, 0.20],
629 [0.99, 0.77, 0.26], 785 [0.99, 0.77, 0.26],
630 [0.74, 0.65, 0.41], 786 [0.74, 0.65, 0.41],
631 ); 787);
632 788
633 my $fg = $color[$color % @color]; 789sub msg {
790 my ($self, $color, $type, $text, @extra) = @_;
634 791
792 $text = sanitise_xml $text;
793
794 if (my $cb = $self->{cb_msg}{$type}) {
795 $_->($self, $color, $type, $text, @extra) for values %$cb;
796 } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) {
797 $type =~ s/-/_/g;
798 $self->{$type} = $text;
799 } else {
635 $self->logprint ("info: ", $text); 800 $self->logprint ("msg: ", $text);
801 return if $color < 0; # negative color == ignore if not understood
636 802
803 my $fg = $CF_COLOR[$color % @CF_COLOR];
804
637 # try to create single paragraphs of multiple lines sent by the server 805 ## try to create single paragraphs of multiple lines sent by the server
806 # no longer neecssary with TRT servers
638 $text =~ s/(?<=\S)\n(?=\w)/ /g; 807 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
639 808
640 $text = CFPlus::asxml $text;
641 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
642 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
643
644 ::message ({ fg => $fg, markup => $_ }) 809 ::message ({ fg => $fg, markup => $_ })
645 for split /\n/, $text; 810 for split /\n/, $text;
646 811
647 $self->{statusbox}->add ($text, 812 $self->{statusbox}->add ($text,
648 group => $text, 813 group => $text,
649 fg => $fg, 814 fg => $fg,
650 timeout => $color >= 2 ? 180 : 10, 815 timeout => $color >= 2 ? 180 : 10,
651 tooltip_font => $::FONT_FIXED, 816 tooltip_font => $::FONT_FIXED,
652 ); 817 );
653} 818 }
654
655sub drawextinfo {
656 my ($self, $color, $type, $subtype, $message) = @_;
657
658 $self->drawinfo ($color, $message);
659} 819}
660 820
661sub spell_add { 821sub spell_add {
662 my ($self, $spell) = @_; 822 my ($self, $spell) = @_;
663 823
679} 839}
680 840
681sub setup { 841sub setup {
682 my ($self, $setup) = @_; 842 my ($self, $setup) = @_;
683 843
844 $self->{map_widget}->set_tilesize ($self->{tilesize});
684 $::MAP->resize ($self->{mapw}, $self->{maph}); 845 $::MAP->resize ($self->{mapw}, $self->{maph});
685} 846}
686 847
687sub addme_success { 848sub addme_success {
688 my ($self) = @_; 849 my ($self) = @_;
895 $::SERVER_INFO->set_markup ( 1056 $::SERVER_INFO->set_markup (
896 "server <tt>$self->{host}:$self->{port}</tt>\n" 1057 "server <tt>$self->{host}:$self->{port}</tt>\n"
897 . "protocol version <tt>$self->{version}</tt>\n" 1058 . "protocol version <tt>$self->{version}</tt>\n"
898 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 1059 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
899 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 1060 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
1061 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
900 . "editing support $yesno[!!$self->{editor_support}]\n" 1062 . "editing support $yesno[!!$self->{editor_support}]\n"
901 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 1063 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
1064 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
902 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 1065 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
903 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 1066 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
904 . "map size $self->{mapw}×$self->{maph}\n" 1067 . "map size $self->{mapw}×$self->{maph}\n"
905 ); 1068 );
906 1069
969 1132
970 (delete $self->{npc_dialog})->destroy 1133 (delete $self->{npc_dialog})->destroy
971 if $self->{npc_dialog}; 1134 if $self->{npc_dialog};
972 1135
973 $self->SUPER::destroy; 1136 $self->SUPER::destroy;
1137
1138 %$self = ();
974} 1139}
975 1140
976package CFPlus::NPCDialog; 1141package CFPlus::NPCDialog;
977 1142
978our @ISA = 'CFPlus::UI::Toplevel'; 1143our @ISA = 'CFPlus::UI::Toplevel';
1069 1234
1070 if ($msg->{msgtype} eq "reply") { 1235 if ($msg->{msgtype} eq "reply") {
1071 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; 1236 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};
1072 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; 1237 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []};
1073 1238
1074 my $text = "\n" . CFPlus::asxml $msg->{msg}; 1239 my $text = "\n" . CFPlus::Protocol::sanitise_xml $msg->{msg};
1075 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} }; 1240 my $match = join "|", map "\\b\Q$_\E\\b", sort { (length $b) <=> (length $a) } keys %{ $self->{kw} };
1076 my @link; 1241 my @link;
1077 $text =~ s{ 1242 $text =~ s{
1078 ($match) 1243 ($match)
1079 }{ 1244 }{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines