… | |
… | |
4 | use strict; |
4 | use strict; |
5 | |
5 | |
6 | use Crossfire::Protocol::Constants; |
6 | use Crossfire::Protocol::Constants; |
7 | |
7 | |
8 | use CFPlus; |
8 | use CFPlus; |
|
|
9 | use CFPlus::DB; |
9 | use CFPlus::UI; |
10 | use CFPlus::UI; |
10 | use CFPlus::Pod; |
11 | use CFPlus::Pod; |
|
|
12 | use CFPlus::Macro; |
|
|
13 | use CFPlus::Item; |
11 | |
14 | |
12 | use Crossfire::Protocol::Base 0.95; |
15 | use Crossfire::Protocol::Base 0.95; |
13 | |
16 | |
14 | use base 'Crossfire::Protocol::Base'; |
17 | use base 'Crossfire::Protocol::Base'; |
15 | |
18 | |
16 | sub new { |
19 | sub new { |
17 | my $class = shift; |
20 | my $class = shift; |
18 | |
21 | |
19 | my $self = $class->SUPER::new (@_, setup_req => { extmap => 1 }); |
22 | my $self = $class->SUPER::new (@_, |
|
|
23 | setup_req => { |
|
|
24 | extmap => 1, |
|
|
25 | smoothing => 1, |
|
|
26 | }, |
|
|
27 | ); |
20 | |
28 | |
21 | $self->{map_widget}->clr_commands; |
29 | $self->{map_widget}->clr_commands; |
22 | |
30 | |
23 | my @cmd_help = map { |
31 | my @cmd_help = map { |
24 | $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
32 | $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x |
… | |
… | |
35 | for @args; |
43 | for @args; |
36 | |
44 | |
37 | map ["$cmd$_", $text], |
45 | map ["$cmd$_", $text], |
38 | sort { (length $a) <=> (length $b) } |
46 | sort { (length $a) <=> (length $b) } |
39 | @args |
47 | @args |
40 | } sort { $a->{par} <=> $b->{par} } |
48 | } sort { $a->{par} <=> $b->{par} } |
41 | CFPlus::Pod::find command => "*"; |
49 | CFPlus::Pod::find command => "*"; |
42 | |
50 | |
|
|
51 | $self->connect_ext (event_capabilities => sub { |
|
|
52 | my ($cap) = @_; |
|
|
53 | |
|
|
54 | if (my $ts = $cap->{tileset}) { |
|
|
55 | if (my ($default) = grep $_->[2] & 1, @$ts) { |
|
|
56 | $self->{tileset} = $default; |
|
|
57 | $self->{tilesize} = $default->[3]; |
|
|
58 | $self->setup_req (tileset => $default->[0]); |
|
|
59 | |
|
|
60 | my $w = int $self->{mapw} * 32 / $self->{tilesize}; |
|
|
61 | my $h = int $self->{maph} * 32 / $self->{tilesize}; |
|
|
62 | |
|
|
63 | $self->setup_req (mapsize => "${w}x${h}"); |
|
|
64 | } |
|
|
65 | } |
|
|
66 | }); |
|
|
67 | |
43 | $self->{map_widget}->add_command (@$_) |
68 | $self->{map_widget}->add_command (@$_) |
44 | for @cmd_help; |
69 | for @cmd_help; |
45 | |
|
|
46 | $self->{noface} = new_from_file CFPlus::Texture |
|
|
47 | CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; |
|
|
48 | |
70 | |
49 | { |
71 | { |
50 | $self->{dialogue} = my $tex = new_from_file CFPlus::Texture |
72 | $self->{dialogue} = my $tex = new_from_file CFPlus::Texture |
51 | CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; |
73 | CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; |
52 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
74 | $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
53 | } |
75 | } |
54 | |
76 | |
|
|
77 | { |
|
|
78 | $self->{noface} = my $tex = new_from_file CFPlus::Texture |
|
|
79 | CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1; |
|
|
80 | $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
81 | } |
|
|
82 | |
55 | $self->{open_container} = 0; |
83 | $self->{open_container} = 0; |
56 | |
84 | |
57 | # "global" |
|
|
58 | $self->{tilecache} = CFPlus::db_table "tilecache" |
|
|
59 | or die "tilecache: unable to open database table"; |
|
|
60 | $self->{facemap} = CFPlus::db_table "facemap" |
|
|
61 | or die "facemap: unable to open database table"; |
|
|
62 | |
|
|
63 | # per server |
85 | # per server |
64 | $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}" |
86 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
65 | or die "mapcache_$self->{host}_$self->{port}: unable to open database table"; |
|
|
66 | |
87 | |
67 | $self |
88 | $self |
68 | } |
89 | } |
69 | |
90 | |
70 | sub logprint { |
91 | sub logprint { |
… | |
… | |
288 | if ($ev->{button} == 1) { |
309 | if ($ev->{button} == 1) { |
289 | $::CONN->user_send ("ready_skill $name"); |
310 | $::CONN->user_send ("ready_skill $name"); |
290 | } elsif ($ev->{button} == 2) { |
311 | } elsif ($ev->{button} == 2) { |
291 | $::CONN->user_send ("use_skill $name"); |
312 | $::CONN->user_send ("use_skill $name"); |
292 | } elsif ($ev->{button} == 3) { |
313 | } elsif ($ev->{button} == 3) { |
|
|
314 | my $shortname = CFPlus::shorten $name, 14; |
293 | (new CFPlus::UI::Menu |
315 | (new CFPlus::UI::Menu |
294 | items => [ |
316 | items => [ |
295 | ["bind <i>ready_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }], |
317 | ["bind <i>ready_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["ready_skill $name"] }], |
296 | ["bind <i>use_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["use_skill $name"]) }], |
318 | ["bind <i>use_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["use_skill $name"] }], |
297 | ], |
319 | ], |
298 | )->popup ($ev); |
320 | )->popup ($ev); |
299 | } else { |
321 | } else { |
300 | return 0; |
322 | return 0; |
301 | } |
323 | } |
… | |
… | |
318 | $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); |
340 | $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); |
319 | $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); |
341 | $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); |
320 | } |
342 | } |
321 | } |
343 | } |
322 | |
344 | |
|
|
345 | sub macro_send { |
|
|
346 | my ($self, $macro) = @_; |
|
|
347 | |
|
|
348 | for my $cmd (@{ $macro->{action} }) { |
|
|
349 | $self->send_command ($cmd); |
|
|
350 | } |
|
|
351 | } |
|
|
352 | |
323 | sub user_send { |
353 | sub user_send { |
324 | my ($self, $command) = @_; |
354 | my ($self, $command) = @_; |
325 | |
355 | |
326 | push @{$self->{record}}, $command |
356 | $self->{record}->($command) |
327 | if $self->{record}; |
357 | if $self->{record}; |
328 | |
358 | |
329 | $self->logprint ("send: ", $command); |
359 | $self->logprint ("send: ", $command); |
330 | $self->send_command ($command); |
360 | $self->send_command ($command); |
331 | ::status ($command); |
361 | ::status ($command); |
332 | } |
362 | } |
333 | |
363 | |
334 | sub start_record { |
364 | sub record { |
335 | my ($self) = @_; |
365 | my ($self, $cb) = @_; |
336 | |
366 | |
337 | $self->{record} = []; |
367 | $self->{record} = $cb; |
338 | } |
|
|
339 | |
|
|
340 | sub stop_record { |
|
|
341 | my ($self) = @_; |
|
|
342 | return delete $self->{record}; |
|
|
343 | } |
368 | } |
344 | |
369 | |
345 | sub map_scroll { |
370 | sub map_scroll { |
346 | my ($self, $dx, $dy) = @_; |
371 | my ($self, $dx, $dy) = @_; |
347 | |
372 | |
… | |
… | |
368 | or return; |
393 | or return; |
369 | |
394 | |
370 | my ($hash, $x, $y, $w, $h) = @$map_info; |
395 | my ($hash, $x, $y, $w, $h) = @$map_info; |
371 | |
396 | |
372 | my $data = $self->{map}->get_rect ($x, $y, $w, $h); |
397 | my $data = $self->{map}->get_rect ($x, $y, $w, $h); |
373 | $self->{mapcache}->put ($hash => Compress::LZF::compress $data); |
398 | CFPlus::DB::put $self->{mapcache} => $hash => Compress::LZF::compress $data, sub { }; |
374 | #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
399 | #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
375 | } |
400 | } |
376 | |
401 | |
377 | sub map_clear { |
402 | sub map_clear { |
378 | my ($self) = @_; |
403 | my ($self) = @_; |
… | |
… | |
382 | |
407 | |
383 | $self->{map}->clear; |
408 | $self->{map}->clear; |
384 | delete $self->{map_widget}{magicmap}; |
409 | delete $self->{map_widget}{magicmap}; |
385 | } |
410 | } |
386 | |
411 | |
|
|
412 | sub bg_fetch { |
|
|
413 | my ($self) = @_; |
|
|
414 | |
|
|
415 | my $id; |
|
|
416 | |
|
|
417 | do { |
|
|
418 | $id = pop @{$self->{bg_fetch}} |
|
|
419 | or return; |
|
|
420 | } while $self->{texture}[$id]; |
|
|
421 | |
|
|
422 | CFPlus::DB::get tilecache => $id, sub { |
|
|
423 | my ($data) = @_; |
|
|
424 | |
|
|
425 | return unless $self->{map}; # stop when destroyed |
|
|
426 | |
|
|
427 | $self->set_texture ($id => $data) |
|
|
428 | if defined $data; |
|
|
429 | |
|
|
430 | $self->bg_fetch; |
|
|
431 | }; |
|
|
432 | } |
387 | |
433 | |
388 | sub load_map($$$) { |
434 | sub load_map($$$) { |
389 | my ($self, $hash, $x, $y) = @_; |
435 | my ($self, $hash, $x, $y) = @_; |
390 | |
436 | |
391 | if (defined (my $data = $self->{mapcache}->get ($hash))) { |
437 | CFPlus::DB::get $self->{mapcache} => $hash, sub { |
|
|
438 | my ($data) = @_; |
|
|
439 | |
|
|
440 | if (defined $data) { |
392 | $data = Compress::LZF::decompress $data; |
441 | $data = Compress::LZF::decompress $data; |
393 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
442 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
394 | for my $id ($self->{map}->set_rect ($x, $y, $data)) { |
|
|
395 | my $data = $self->{tilecache}->get ($id) |
|
|
396 | or next; |
|
|
397 | |
443 | |
398 | $self->set_texture ($id => $data); |
444 | my $inprogress = @{ $self->{bg_fetch} || [] }; |
|
|
445 | unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); |
|
|
446 | $self->bg_fetch unless $inprogress; |
399 | } |
447 | } |
400 | } |
448 | }; |
401 | } |
449 | } |
402 | |
450 | |
403 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
451 | # hardcode /world/world_xxx_xxx map names, the savings are enourmous, |
404 | # (server resource,s latency, bandwidth), so this hack is warranted. |
452 | # (server resource,s latency, bandwidth), so this hack is warranted. |
405 | # the right fix is to make real tiled maps with an overview file |
453 | # the right fix is to make real tiled maps with an overview file |
… | |
… | |
519 | $self->load_map ($hash, $x, $y); |
567 | $self->load_map ($hash, $x, $y); |
520 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
568 | $self->flood_fill (0, 0, 0, "", $hash, $flags); |
521 | } |
569 | } |
522 | |
570 | |
523 | sub face_find { |
571 | sub face_find { |
524 | my ($self, $facenum, $face) = @_; |
572 | my ($self, $facenum, $face, $cb) = @_; |
525 | |
573 | |
526 | my $hash = "$face->{chksum},$face->{name}"; |
574 | my $hash = "$face->{chksum},$face->{name}"; |
527 | |
575 | |
528 | my $id = $self->{facemap}->get ($hash); |
576 | my $id = CFPlus::DB::get_tile_id_sync $hash; |
529 | |
577 | |
530 | unless ($id) { |
|
|
531 | # create new id for face |
|
|
532 | # I love transactions |
|
|
533 | for (1..100) { |
|
|
534 | my $txn = $CFPlus::DB_ENV->txn_begin; |
|
|
535 | my $status = $self->{facemap}->db_get (id => $id); |
|
|
536 | if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) { |
|
|
537 | $id = ($id || 64) + 1; |
|
|
538 | if ($self->{facemap}->put (id => $id) == 0 |
|
|
539 | && $self->{facemap}->put ($hash => $id) == 0) { |
|
|
540 | $txn->txn_commit; |
|
|
541 | |
|
|
542 | goto gotid; |
|
|
543 | } |
|
|
544 | } |
|
|
545 | $txn->txn_abort; |
|
|
546 | } |
|
|
547 | |
|
|
548 | CFPlus::fatal "maximum number of transaction retries reached - database problems?"; |
|
|
549 | } |
|
|
550 | |
|
|
551 | gotid: |
|
|
552 | $face->{id} = $id; |
578 | $face->{id} = $id; |
553 | $self->{map}->set_face ($facenum => $id); |
|
|
554 | $self->{faceid}[$facenum] = $id;#d# |
579 | $self->{faceid}[$facenum] = $id; |
555 | |
580 | |
556 | my $face = $self->{tilecache}->get ($id); |
581 | $self->{map}->set_tileid ($facenum => $id); |
557 | |
582 | |
558 | if ($face) { |
583 | CFPlus::DB::get tilecache => $id, $cb; |
559 | #$self->face_prefetch; |
|
|
560 | $face |
|
|
561 | } else { |
|
|
562 | my $tex = $self->{noface}; |
|
|
563 | $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
|
|
564 | undef |
|
|
565 | }; |
|
|
566 | } |
584 | } |
567 | |
585 | |
568 | sub face_update { |
586 | sub face_update { |
569 | my ($self, $facenum, $face, $changed) = @_; |
587 | my ($self, $facenum, $face, $changed) = @_; |
570 | |
588 | |
571 | $self->{tilecache}->put ($face->{id} => $face->{image}) if $changed; |
589 | CFPlus::DB::put tilecache => $face->{id} => $face->{image}, sub { } |
|
|
590 | if $changed; |
572 | |
591 | |
573 | $self->set_texture ($face->{id} => delete $face->{image}); |
592 | $self->set_texture ($face->{id} => delete $face->{image}); |
|
|
593 | } |
|
|
594 | |
|
|
595 | sub smooth_update { |
|
|
596 | my ($self, $facenum, $face) = @_; |
|
|
597 | |
|
|
598 | $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel}); |
574 | } |
599 | } |
575 | |
600 | |
576 | sub set_texture { |
601 | sub set_texture { |
577 | my ($self, $id, $data) = @_; |
602 | my ($self, $id, $data) = @_; |
578 | |
603 | |
579 | $self->{texture}[$id] ||= do { |
604 | $self->{texture}[$id] = my $tex = |
580 | my $tex = |
|
|
581 | new_from_image CFPlus::Texture |
605 | new_from_image CFPlus::Texture |
582 | $data, minify => 1, mipmap => 1; |
606 | $data, minify => 1, mipmap => 1; |
583 | |
607 | |
584 | $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
608 | $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
585 | $self->{map_widget}->update; |
609 | $self->{map_widget}->update; |
586 | |
|
|
587 | $tex |
|
|
588 | }; |
|
|
589 | } |
610 | } |
590 | |
611 | |
591 | sub sound_play { |
612 | sub sound_play { |
592 | my ($self, $x, $y, $soundnum, $type) = @_; |
613 | my ($self, $x, $y, $soundnum, $type) = @_; |
593 | |
614 | |
… | |
… | |
622 | [0.75, 0.61, 0.20], |
643 | [0.75, 0.61, 0.20], |
623 | [0.99, 0.77, 0.26], |
644 | [0.99, 0.77, 0.26], |
624 | [0.74, 0.65, 0.41], |
645 | [0.74, 0.65, 0.41], |
625 | ); |
646 | ); |
626 | |
647 | |
|
|
648 | my $fg = $color[$color % @color]; |
|
|
649 | |
627 | $self->logprint ("info: ", $text); |
650 | $self->logprint ("info: ", $text); |
628 | |
651 | |
629 | # try to create single paragraphs of multiple lines sent by the server |
652 | # try to create single paragraphs of multiple lines sent by the server |
630 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
653 | $text =~ s/(?<=\S)\n(?=\w)/ /g; |
631 | |
654 | |
632 | $text = CFPlus::asxml $text; |
655 | $text = CFPlus::asxml $text; |
633 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
656 | $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; |
634 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
657 | $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; |
635 | |
658 | |
636 | ::message ({ fg => $color[$color], markup => $_ }) |
659 | ::message ({ fg => $fg, markup => $_ }) |
637 | for split /\n/, $text; |
660 | for split /\n/, $text; |
638 | |
661 | |
639 | $self->{statusbox}->add ($text, |
662 | $self->{statusbox}->add ($text, |
640 | group => $text, |
663 | group => $text, |
641 | fg => $color[$color], |
664 | fg => $fg, |
642 | timeout => $color >= 2 ? 180 : 10, |
665 | timeout => $color >= 2 ? 180 : 10, |
643 | tooltip_font => $::FONT_FIXED, |
666 | tooltip_font => $::FONT_FIXED, |
644 | ); |
667 | ); |
645 | } |
668 | } |
646 | |
669 | |
… | |
… | |
671 | } |
694 | } |
672 | |
695 | |
673 | sub setup { |
696 | sub setup { |
674 | my ($self, $setup) = @_; |
697 | my ($self, $setup) = @_; |
675 | |
698 | |
|
|
699 | $self->{map_widget}->set_tilesize ($self->{tilesize}); |
676 | $::MAP->resize ($self->{mapw}, $self->{maph}); |
700 | $::MAP->resize ($self->{mapw}, $self->{maph}); |
677 | } |
701 | } |
678 | |
702 | |
679 | sub addme_success { |
703 | sub addme_success { |
680 | my ($self) = @_; |
704 | my ($self) = @_; |
… | |
… | |
893 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
917 | . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" |
894 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
918 | . "cfplus support $yesno[$self->{cfplus_ext} > 0]" |
895 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
919 | . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" |
896 | . "map size $self->{mapw}×$self->{maph}\n" |
920 | . "map size $self->{mapw}×$self->{maph}\n" |
897 | ); |
921 | ); |
|
|
922 | |
|
|
923 | ::setup_build_button ($self->{editor_support}->{builder_ui}); |
898 | } |
924 | } |
899 | |
925 | |
900 | sub logged_in { |
926 | sub logged_in { |
901 | my ($self) = @_; |
927 | my ($self) = @_; |
902 | |
928 | |
… | |
… | |
918 | |
944 | |
919 | $self->update_server_info; |
945 | $self->update_server_info; |
920 | |
946 | |
921 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
947 | $self->send_command ("output-sync $::CFG->{output_sync}"); |
922 | $self->send_command ("output-count $::CFG->{output_count}"); |
948 | $self->send_command ("output-count $::CFG->{output_count}"); |
|
|
949 | $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0; |
923 | $self->send_command ("pickup $::CFG->{pickup}"); |
950 | $self->send_command ("pickup $::CFG->{pickup}"); |
|
|
951 | } |
|
|
952 | |
|
|
953 | sub buildat { |
|
|
954 | my ($self, $builditem, $x, $y) = @_; |
|
|
955 | |
|
|
956 | if ($self->{cfplus_ext}) { |
|
|
957 | $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem)); |
|
|
958 | } |
924 | } |
959 | } |
925 | |
960 | |
926 | sub lookat { |
961 | sub lookat { |
927 | my ($self, $x, $y) = @_; |
962 | my ($self, $x, $y) = @_; |
928 | |
963 | |
… | |
… | |
971 | kw => { hi => 0, yes => 0, no => 0 }, |
1006 | kw => { hi => 0, yes => 0, no => 0 }, |
972 | has_close_button => 1, |
1007 | has_close_button => 1, |
973 | @_, |
1008 | @_, |
974 | ); |
1009 | ); |
975 | |
1010 | |
976 | Scalar::Util::weaken (my $this = $self); |
1011 | CFPlus::weaken (my $this = $self); |
977 | |
1012 | |
978 | $self->connect (delete => sub { $this->destroy; 1 }); |
1013 | $self->connect (delete => sub { $this->destroy; 1 }); |
979 | |
1014 | |
980 | # better use a pane... |
1015 | # better use a pane... |
981 | $self->add (my $hbox = new CFPlus::UI::HBox); |
1016 | $self->add (my $hbox = new CFPlus::UI::HBox); |
… | |
… | |
1025 | }; |
1060 | }; |
1026 | |
1061 | |
1027 | sub update_options { |
1062 | sub update_options { |
1028 | my ($self) = @_; |
1063 | my ($self) = @_; |
1029 | |
1064 | |
1030 | Scalar::Util::weaken $self; |
1065 | CFPlus::weaken $self; |
1031 | |
1066 | |
1032 | $self->{options}->clear; |
1067 | $self->{options}->clear; |
1033 | $self->{options}->add ($self->{bye_button}); |
1068 | $self->{options}->add ($self->{bye_button}); |
1034 | |
1069 | |
1035 | for my $kw (sort keys %{ $self->{kw} }) { |
1070 | for my $kw (sort keys %{ $self->{kw} }) { |
… | |
… | |
1044 | } |
1079 | } |
1045 | |
1080 | |
1046 | sub feed { |
1081 | sub feed { |
1047 | my ($self, $msg) = @_; |
1082 | my ($self, $msg) = @_; |
1048 | |
1083 | |
1049 | Scalar::Util::weaken $self; |
1084 | CFPlus::weaken $self; |
1050 | |
1085 | |
1051 | if ($msg->{msgtype} eq "reply") { |
1086 | if ($msg->{msgtype} eq "reply") { |
1052 | $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; |
1087 | $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; |
1053 | $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; |
1088 | $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; |
1054 | |
1089 | |