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.89 by elmex, Mon Dec 4 15:17:14 2006 UTC vs.
Revision 1.106 by root, Sun Apr 29 20:03:08 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;
12use CFPlus::Macro;
13use CFPlus::Item;
11 14
12use Crossfire::Protocol::Base 0.95; 15use Crossfire::Protocol::Base 0.95;
13 16
14use base 'Crossfire::Protocol::Base'; 17use base 'Crossfire::Protocol::Base';
15 18
16sub new { 19sub new {
17 my $class = shift; 20 my ($class, %arg) = @_;
18 21
19 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 %{$arg{setup_req} || {}},
27 },
28 );
20 29
21 $self->{map_widget}->clr_commands; 30 $self->{map_widget}->clr_commands;
22 31
23 my @cmd_help = map { 32 my @cmd_help = map {
24 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 33 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
35 for @args; 44 for @args;
36 45
37 map ["$cmd$_", $text], 46 map ["$cmd$_", $text],
38 sort { (length $a) <=> (length $b) } 47 sort { (length $a) <=> (length $b) }
39 @args 48 @args
40 } sort { $a->{par} <=> $b->{par} } 49 } sort { $a->{par} <=> $b->{par} }
41 CFPlus::Pod::find command => "*"; 50 CFPlus::Pod::find command => "*";
42 51
52 $self->connect_ext (event_capabilities => sub {
53 my ($cap) = @_;
54
55 if (my $ts = $cap->{tileset}) {
56 if (my ($default) = grep $_->[2] & 1, @$ts) {
57 $self->{tileset} = $default;
58 $self->{tilesize} = $default->[3];
59 $self->setup_req (tileset => $default->[0]);
60
61 my $w = int $self->{mapw} * 32 / $self->{tilesize};
62 my $h = int $self->{maph} * 32 / $self->{tilesize};
63
64 $self->setup_req (mapsize => "${w}x${h}");
65 }
66 }
67 });
68
43 $self->{map_widget}->add_command (@$_) 69 $self->{map_widget}->add_command (@$_)
44 for @cmd_help; 70 for @cmd_help;
45
46 $self->{noface} = new_from_file CFPlus::Texture
47 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1;
48 71
49 { 72 {
50 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture 73 $self->{dialogue} = my $tex = new_from_file CFPlus::Texture
51 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1; 74 CFPlus::find_rcfile "dialogue.png", minify => 1, mipmap => 1;
52 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 75 $self->{map}->set_texture (1, @$tex{qw(name w h s t)}, @{$tex->{minified}});
53 } 76 }
54 77
78 {
79 $self->{noface} = my $tex = new_from_file CFPlus::Texture
80 CFPlus::find_rcfile "noface.png", minify => 1, mipmap => 1;
81 $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}});
82 }
83
55 $self->{open_container} = 0; 84 $self->{open_container} = 0;
56 85
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 86 # per server
64 $self->{mapcache} = CFPlus::db_table "mapcache_$self->{host}_$self->{port}" 87 $self->{mapcache} = "mapcache_$self->{host}_$self->{port}";
65 or die "mapcache_$self->{host}_$self->{port}: unable to open database table";
66 88
67 $self 89 $self
68} 90}
69 91
70sub logprint { 92sub logprint {
227 $::GAUGES->{mana} ->set_value ($sp, $sp_m); 249 $::GAUGES->{mana} ->set_value ($sp, $sp_m);
228 $::GAUGES->{food} ->set_value ($fo, $fo_m); 250 $::GAUGES->{food} ->set_value ($fo, $fo_m);
229 $::GAUGES->{grace} ->set_value ($gr, $gr_m); 251 $::GAUGES->{grace} ->set_value ($gr, $gr_m);
230 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64})) 252 $::GAUGES->{exp} ->set_text ("Exp: " . (::formsep ($stats->{+CS_STAT_EXP64}))
231 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")"); 253 . " (lvl " . ($stats->{+CS_STAT_LEVEL} * 1) . ")");
232 my $rng = $stats->{+CS_STAT_RANGE}; 254 $::GAUGES->{range} ->set_text ($stats->{+CS_STAT_RANGE});
233 $rng =~ s/^Range: //; # thank you so much dear server
234 $::GAUGES->{range} ->set_text ("Rng: " . $rng);
235 my $title = $stats->{+CS_STAT_TITLE}; 255 my $title = $stats->{+CS_STAT_TITLE};
236 $title =~ s/^Player: //; 256 $title =~ s/^Player: //;
237 $::STATWIDS->{title} ->set_text ("Title: " . $title); 257 $::STATWIDS->{title} ->set_text ("Title: " . $title);
238 258
239 $::STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR}); 259 $::STATWIDS->{st_str} ->set_text (sprintf "%d" , $stats->{+CS_STAT_STR});
288 if ($ev->{button} == 1) { 308 if ($ev->{button} == 1) {
289 $::CONN->user_send ("ready_skill $name"); 309 $::CONN->user_send ("ready_skill $name");
290 } elsif ($ev->{button} == 2) { 310 } elsif ($ev->{button} == 2) {
291 $::CONN->user_send ("use_skill $name"); 311 $::CONN->user_send ("use_skill $name");
292 } elsif ($ev->{button} == 3) { 312 } elsif ($ev->{button} == 3) {
313 my $shortname = CFPlus::shorten $name, 14;
293 (new CFPlus::UI::Menu 314 (new CFPlus::UI::Menu
294 items => [ 315 items => [
295 ["bind <i>ready_skill $name</i> to a key" => sub { $::BIND_EDITOR->do_quick_binding (["ready_skill $name"]) }], 316 ["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"]) }], 317 ["bind <i>use_skill $shortname</i> to a key" => sub { CFPlus::Macro::quick_macro ["use_skill $name"] }],
297 ], 318 ],
298 )->popup ($ev); 319 )->popup ($ev);
299 } else { 320 } else {
300 return 0; 321 return 0;
301 } 322 }
318 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 339 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
319 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 340 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
320 } 341 }
321} 342}
322 343
344sub macro_send {
345 my ($self, $macro) = @_;
346
347 for my $cmd (@{ $macro->{action} }) {
348 $self->send_command ($cmd);
349 }
350}
351
323sub user_send { 352sub user_send {
324 my ($self, $command) = @_; 353 my ($self, $command) = @_;
325 354
326 push @{$self->{record}}, $command 355 $self->{record}->($command)
327 if $self->{record}; 356 if $self->{record};
328 357
329 $self->logprint ("send: ", $command); 358 $self->logprint ("send: ", $command);
330 $self->send_command ($command); 359 $self->send_command ($command);
331 ::status ($command); 360 ::status ($command);
332} 361}
333 362
334sub start_record { 363sub record {
335 my ($self) = @_; 364 my ($self, $cb) = @_;
336 365
337 $self->{record} = []; 366 $self->{record} = $cb;
338}
339
340sub stop_record {
341 my ($self) = @_;
342 return delete $self->{record};
343} 367}
344 368
345sub map_scroll { 369sub map_scroll {
346 my ($self, $dx, $dy) = @_; 370 my ($self, $dx, $dy) = @_;
347 371
368 or return; 392 or return;
369 393
370 my ($hash, $x, $y, $w, $h) = @$map_info; 394 my ($hash, $x, $y, $w, $h) = @$map_info;
371 395
372 my $data = $self->{map}->get_rect ($x, $y, $w, $h); 396 my $data = $self->{map}->get_rect ($x, $y, $w, $h);
373 $self->{mapcache}->put ($hash => Compress::LZF::compress $data); 397 CFPlus::DB::put $self->{mapcache} => $hash => Compress::LZF::compress $data, sub { };
374 #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# 398 #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d#
375} 399}
376 400
377sub map_clear { 401sub map_clear {
378 my ($self) = @_; 402 my ($self) = @_;
382 406
383 $self->{map}->clear; 407 $self->{map}->clear;
384 delete $self->{map_widget}{magicmap}; 408 delete $self->{map_widget}{magicmap};
385} 409}
386 410
411sub bg_fetch {
412 my ($self) = @_;
413
414 my $id;
415
416 do {
417 $id = pop @{$self->{bg_fetch}}
418 or return;
419 } while $self->{texture}[$id];
420
421 CFPlus::DB::get tilecache => $id, sub {
422 my ($data) = @_;
423
424 return unless $self->{map}; # stop when destroyed
425
426 $self->set_texture ($id => $data)
427 if defined $data;
428
429 $self->bg_fetch;
430 };
431}
387 432
388sub load_map($$$) { 433sub load_map($$$) {
389 my ($self, $hash, $x, $y) = @_; 434 my ($self, $hash, $x, $y) = @_;
390 435
391 if (defined (my $data = $self->{mapcache}->get ($hash))) { 436 my $gen = $self->{map_change_gen};
437
438 CFPlus::DB::get $self->{mapcache} => $hash, sub {
439 return unless $gen == $self->{map_change_gen};
440
441 my ($data) = @_;
442
443 if (defined $data) {
392 $data = Compress::LZF::decompress $data; 444 $data = Compress::LZF::decompress $data;
393 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# 445 #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 446
398 $self->set_texture ($id => $data); 447 my $inprogress = @{ $self->{bg_fetch} || [] };
448 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data);
449 $self->bg_fetch unless $inprogress;
399 } 450 }
400 } 451 };
401} 452}
402 453
403# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 454# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
404# (server resource,s latency, bandwidth), so this hack is warranted. 455# (server resource,s latency, bandwidth), so this hack is warranted.
405# the right fix is to make real tiled maps with an overview file 456# the right fix is to make real tiled maps with an overview file
469 520
470 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 521 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
471 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 522 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
472 523
473 } else { 524 } else {
525 my $gen = $self->{map_change_gen};
474 $self->send_mapinfo ("spatial $path$tile", sub { 526 $self->send_mapinfo ("spatial $path$tile", sub {
527 return unless $gen == $self->{map_change_gen};
528
475 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 529 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
476 530
477 return if $mode ne "spatial"; 531 return if $mode ne "spatial";
478 532
479 $x += $self->{map}->ox; 533 $x += $self->{map}->ox;
493 547
494sub map_change { 548sub map_change {
495 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 549 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
496 550
497 $self->flush_map; 551 $self->flush_map;
552
553 ++$self->{map_change_gen};
498 554
499 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 555 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
500 556
501 my $mapmapw = $self->{mapmap}->{w}; 557 my $mapmapw = $self->{mapmap}->{w};
502 my $mapmaph = $self->{mapmap}->{h}; 558 my $mapmaph = $self->{mapmap}->{h};
519 $self->load_map ($hash, $x, $y); 575 $self->load_map ($hash, $x, $y);
520 $self->flood_fill (0, 0, 0, "", $hash, $flags); 576 $self->flood_fill (0, 0, 0, "", $hash, $flags);
521} 577}
522 578
523sub face_find { 579sub face_find {
524 my ($self, $facenum, $face) = @_; 580 my ($self, $facenum, $face, $cb) = @_;
525 581
526 my $hash = "$face->{chksum},$face->{name}"; 582 my $hash = "$face->{chksum},$face->{name}";
527 583
528 my $id = $self->{facemap}->get ($hash); 584 my $id = CFPlus::DB::get_tile_id_sync $hash;
529 585
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
551gotid:
552 $face->{id} = $id; 586 $face->{id} = $id;
553 $self->{map}->set_face ($facenum => $id);
554 $self->{faceid}[$facenum] = $id;#d# 587 $self->{faceid}[$facenum] = $id;
555 588
556 my $face = $self->{tilecache}->get ($id); 589 $self->{map}->set_tileid ($facenum => $id);
557 590
558 if ($face) { 591 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} 592}
567 593
568sub face_update { 594sub face_update {
569 my ($self, $facenum, $face, $changed) = @_; 595 my ($self, $facenum, $face, $changed) = @_;
570 596
571 $self->{tilecache}->put ($face->{id} => $face->{image}) if $changed; 597 CFPlus::DB::put tilecache => $face->{id} => $face->{image}, sub { }
598 if $changed;
572 599
573 $self->set_texture ($face->{id} => delete $face->{image}); 600 $self->set_texture ($face->{id} => delete $face->{image});
601}
602
603sub smooth_update {
604 my ($self, $facenum, $face) = @_;
605
606 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel});
574} 607}
575 608
576sub set_texture { 609sub set_texture {
577 my ($self, $id, $data) = @_; 610 my ($self, $id, $data) = @_;
578 611
579 $self->{texture}[$id] ||= do { 612 $self->{texture}[$id] = my $tex =
580 my $tex =
581 new_from_image CFPlus::Texture 613 new_from_image CFPlus::Texture
582 $data, minify => 1, mipmap => 1; 614 $data, minify => 1, mipmap => 1;
583 615
584 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 616 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
585 $self->{map_widget}->update; 617 $self->{map_widget}->update;
586
587 $tex
588 };
589} 618}
590 619
591sub sound_play { 620sub sound_play {
592 my ($self, $x, $y, $soundnum, $type) = @_; 621 my ($self, $x, $y, $soundnum, $type) = @_;
593 622
603 $LAST_QUERY = $prompt; 632 $LAST_QUERY = $prompt;
604 633
605 $self->{query}-> ($self, $flags, $prompt); 634 $self->{query}-> ($self, $flags, $prompt);
606} 635}
607 636
608sub drawinfo { 637our %NAME_TO_COLOR = (
609 my ($self, $color, $text) = @_; 638 black => 0,
639 white => 1,
640 darkblue => 2,
641 red => 3,
642 orange => 4,
643 lightblue => 5,
644 darkorange => 6,
645 green => 7,
646 darkgreen => 8,
647 grey => 9,
648 brown => 10,
649 yellow => 11,
650 tan => 12,
651);
610 652
611 my @color = ( 653our @CF_COLOR = (
612 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00], 654 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
613 [1.00, 1.00, 1.00], 655 [1.00, 1.00, 1.00],
614 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55] 656 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
615 [1.00, 0.00, 0.00], 657 [1.00, 0.00, 0.00],
616 [1.00, 0.54, 0.00], 658 [1.00, 0.54, 0.00],
617 [0.11, 0.56, 1.00], 659 [0.11, 0.56, 1.00],
618 [0.93, 0.46, 0.00], 660 [0.93, 0.46, 0.00],
619 [0.18, 0.54, 0.34], 661 [0.18, 0.54, 0.34],
620 [0.56, 0.73, 0.56], 662 [0.56, 0.73, 0.56],
621 [0.80, 0.80, 0.80], 663 [0.80, 0.80, 0.80],
622 [0.75, 0.61, 0.20], 664 [0.75, 0.61, 0.20],
623 [0.99, 0.77, 0.26], 665 [0.99, 0.77, 0.26],
624 [0.74, 0.65, 0.41], 666 [0.74, 0.65, 0.41],
625 ); 667);
626 668
669sub msg {
670 my ($self, $color, $type, $text, @extra) = @_;
671
672 if (my $cb = $self->{cb_msg}{$type}) {
673 $_->($self, $color, $type, $text, @extra) for values %$cb;
674 } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) {
675 $type =~ s/-/_/g;
676 $self->{$type} = $text;
677 } else {
627 $self->logprint ("info: ", $text); 678 $self->logprint ("msg: ", $text);
679 return if $color < 0; # negative color == ignore if not understood
628 680
681 my $fg = $CF_COLOR[$color % @CF_COLOR];
682
629 # try to create single paragraphs of multiple lines sent by the server 683 ## try to create single paragraphs of multiple lines sent by the server
684 # no longer neecssary with TRT servers
630 $text =~ s/(?<=\S)\n(?=\w)/ /g; 685 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
631 686
632 $text = CFPlus::asxml $text;
633 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
634 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
635
636 ::message ({ fg => $color[$color], markup => $_ }) 687 ::message ({ fg => $fg, markup => $_ })
637 for split /\n/, $text; 688 for split /\n/, $text;
638 689
639 $self->{statusbox}->add ($text, 690 $self->{statusbox}->add ($text,
640 group => $text, 691 group => $text,
641 fg => $color[$color], 692 fg => $fg,
642 timeout => $color >= 2 ? 180 : 10, 693 timeout => $color >= 2 ? 180 : 10,
643 tooltip_font => $::FONT_FIXED, 694 tooltip_font => $::FONT_FIXED,
644 ); 695 );
645} 696 }
646
647sub drawextinfo {
648 my ($self, $color, $type, $subtype, $message) = @_;
649
650 $self->drawinfo ($color, $message);
651} 697}
652 698
653sub spell_add { 699sub spell_add {
654 my ($self, $spell) = @_; 700 my ($self, $spell) = @_;
655 701
671} 717}
672 718
673sub setup { 719sub setup {
674 my ($self, $setup) = @_; 720 my ($self, $setup) = @_;
675 721
722 $self->{map_widget}->set_tilesize ($self->{tilesize});
676 $::MAP->resize ($self->{mapw}, $self->{maph}); 723 $::MAP->resize ($self->{mapw}, $self->{maph});
677} 724}
678 725
679sub addme_success { 726sub addme_success {
680 my ($self) = @_; 727 my ($self) = @_;
887 $::SERVER_INFO->set_markup ( 934 $::SERVER_INFO->set_markup (
888 "server <tt>$self->{host}:$self->{port}</tt>\n" 935 "server <tt>$self->{host}:$self->{port}</tt>\n"
889 . "protocol version <tt>$self->{version}</tt>\n" 936 . "protocol version <tt>$self->{version}</tt>\n"
890 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 937 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
891 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 938 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
939 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
892 . "editing support $yesno[!!$self->{editor_support}]\n" 940 . "editing support $yesno[!!$self->{editor_support}]\n"
893 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 941 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
942 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
894 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 943 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
895 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 944 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
896 . "map size $self->{mapw}×$self->{maph}\n" 945 . "map size $self->{mapw}×$self->{maph}\n"
897 ); 946 );
898 947
920 969
921 $self->update_server_info; 970 $self->update_server_info;
922 971
923 $self->send_command ("output-sync $::CFG->{output_sync}"); 972 $self->send_command ("output-sync $::CFG->{output_sync}");
924 $self->send_command ("output-count $::CFG->{output_count}"); 973 $self->send_command ("output-count $::CFG->{output_count}");
974 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
925 $self->send_command ("pickup $::CFG->{pickup}"); 975 $self->send_command ("pickup $::CFG->{pickup}");
926} 976}
927 977
928sub buildat { 978sub buildat {
929 my ($self, $builditem, $x, $y) = @_; 979 my ($self, $builditem, $x, $y) = @_;
981 kw => { hi => 0, yes => 0, no => 0 }, 1031 kw => { hi => 0, yes => 0, no => 0 },
982 has_close_button => 1, 1032 has_close_button => 1,
983 @_, 1033 @_,
984 ); 1034 );
985 1035
986 Scalar::Util::weaken (my $this = $self); 1036 CFPlus::weaken (my $this = $self);
987 1037
988 $self->connect (delete => sub { $this->destroy; 1 }); 1038 $self->connect (delete => sub { $this->destroy; 1 });
989 1039
990 # better use a pane... 1040 # better use a pane...
991 $self->add (my $hbox = new CFPlus::UI::HBox); 1041 $self->add (my $hbox = new CFPlus::UI::HBox);
1035}; 1085};
1036 1086
1037sub update_options { 1087sub update_options {
1038 my ($self) = @_; 1088 my ($self) = @_;
1039 1089
1040 Scalar::Util::weaken $self; 1090 CFPlus::weaken $self;
1041 1091
1042 $self->{options}->clear; 1092 $self->{options}->clear;
1043 $self->{options}->add ($self->{bye_button}); 1093 $self->{options}->add ($self->{bye_button});
1044 1094
1045 for my $kw (sort keys %{ $self->{kw} }) { 1095 for my $kw (sort keys %{ $self->{kw} }) {
1054} 1104}
1055 1105
1056sub feed { 1106sub feed {
1057 my ($self, $msg) = @_; 1107 my ($self, $msg) = @_;
1058 1108
1059 Scalar::Util::weaken $self; 1109 CFPlus::weaken $self;
1060 1110
1061 if ($msg->{msgtype} eq "reply") { 1111 if ($msg->{msgtype} eq "reply") {
1062 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; 1112 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};
1063 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; 1113 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []};
1064 1114

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines