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.90 by root, Wed Dec 6 00:15:12 2006 UTC vs.
Revision 1.107 by root, Sun Jun 24 03:46:46 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});
291 $::CONN->user_send ("use_skill $name"); 311 $::CONN->user_send ("use_skill $name");
292 } elsif ($ev->{button} == 3) { 312 } elsif ($ev->{button} == 3) {
293 my $shortname = CFPlus::shorten $name, 14; 313 my $shortname = CFPlus::shorten $name, 14;
294 (new CFPlus::UI::Menu 314 (new CFPlus::UI::Menu
295 items => [ 315 items => [
296 ["bind <i>ready_skill $shortname</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"] }],
297 ["bind <i>use_skill $shortname</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"] }],
298 ], 318 ],
299 )->popup ($ev); 319 )->popup ($ev);
300 } else { 320 } else {
301 return 0; 321 return 0;
302 } 322 }
319 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1])); 339 $self->{stat_widget_exp}{$_}->set_text (::formsep ($stats->{$_}[1]));
320 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1); 340 $self->{stat_widget_lvl}{$_}->set_text ($stats->{$_}[0] * 1);
321 } 341 }
322} 342}
323 343
344sub macro_send {
345 my ($self, $macro) = @_;
346
347 for my $cmd (@{ $macro->{action} }) {
348 $self->send_command ($cmd);
349 }
350}
351
324sub user_send { 352sub user_send {
325 my ($self, $command) = @_; 353 my ($self, $command) = @_;
326 354
327 push @{$self->{record}}, $command 355 $self->{record}->($command)
328 if $self->{record}; 356 if $self->{record};
329 357
330 $self->logprint ("send: ", $command); 358 $self->logprint ("send: ", $command);
331 $self->send_command ($command); 359 $self->send_command ($command);
332 ::status ($command); 360 ::status ($command);
333} 361}
334 362
335sub start_record { 363sub record {
336 my ($self) = @_; 364 my ($self, $cb) = @_;
337 365
338 $self->{record} = []; 366 $self->{record} = $cb;
339}
340
341sub stop_record {
342 my ($self) = @_;
343 return delete $self->{record};
344} 367}
345 368
346sub map_scroll { 369sub map_scroll {
347 my ($self, $dx, $dy) = @_; 370 my ($self, $dx, $dy) = @_;
348 371
369 or return; 392 or return;
370 393
371 my ($hash, $x, $y, $w, $h) = @$map_info; 394 my ($hash, $x, $y, $w, $h) = @$map_info;
372 395
373 my $data = $self->{map}->get_rect ($x, $y, $w, $h); 396 my $data = $self->{map}->get_rect ($x, $y, $w, $h);
374 $self->{mapcache}->put ($hash => Compress::LZF::compress $data); 397 CFPlus::DB::put $self->{mapcache} => $hash => Compress::LZF::compress $data, sub { };
375 #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# 398 #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d#
376} 399}
377 400
378sub map_clear { 401sub map_clear {
379 my ($self) = @_; 402 my ($self) = @_;
383 406
384 $self->{map}->clear; 407 $self->{map}->clear;
385 delete $self->{map_widget}{magicmap}; 408 delete $self->{map_widget}{magicmap};
386} 409}
387 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}
388 432
389sub load_map($$$) { 433sub load_map($$$) {
390 my ($self, $hash, $x, $y) = @_; 434 my ($self, $hash, $x, $y) = @_;
391 435
392 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) {
393 $data = Compress::LZF::decompress $data; 444 $data = Compress::LZF::decompress $data;
394 #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#
395 for my $id ($self->{map}->set_rect ($x, $y, $data)) {
396 my $data = $self->{tilecache}->get ($id)
397 or next;
398 446
399 $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;
400 } 450 }
401 } 451 };
402} 452}
403 453
404# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 454# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
405# (server resource,s latency, bandwidth), so this hack is warranted. 455# (server resource,s latency, bandwidth), so this hack is warranted.
406# 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
470 520
471 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 521 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
472 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 522 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
473 523
474 } else { 524 } else {
525 my $gen = $self->{map_change_gen};
475 $self->send_mapinfo ("spatial $path$tile", sub { 526 $self->send_mapinfo ("spatial $path$tile", sub {
527 return unless $gen == $self->{map_change_gen};
528
476 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 529 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
477 530
478 return if $mode ne "spatial"; 531 return if $mode ne "spatial";
479 532
480 $x += $self->{map}->ox; 533 $x += $self->{map}->ox;
494 547
495sub map_change { 548sub map_change {
496 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 549 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
497 550
498 $self->flush_map; 551 $self->flush_map;
552
553 ++$self->{map_change_gen};
499 554
500 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 555 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
501 556
502 my $mapmapw = $self->{mapmap}->{w}; 557 my $mapmapw = $self->{mapmap}->{w};
503 my $mapmaph = $self->{mapmap}->{h}; 558 my $mapmaph = $self->{mapmap}->{h};
520 $self->load_map ($hash, $x, $y); 575 $self->load_map ($hash, $x, $y);
521 $self->flood_fill (0, 0, 0, "", $hash, $flags); 576 $self->flood_fill (0, 0, 0, "", $hash, $flags);
522} 577}
523 578
524sub face_find { 579sub face_find {
525 my ($self, $facenum, $face) = @_; 580 my ($self, $facenum, $face, $cb) = @_;
526 581
527 my $hash = "$face->{chksum},$face->{name}"; 582 my $hash = "$face->{chksum},$face->{name}";
528 583
529 my $id = $self->{facemap}->get ($hash); 584 my $id = CFPlus::DB::get_tile_id_sync $hash;
530 585
531 unless ($id) {
532 # create new id for face
533 # I love transactions
534 for (1..100) {
535 my $txn = $CFPlus::DB_ENV->txn_begin;
536 my $status = $self->{facemap}->db_get (id => $id);
537 if ($status == 0 || $status == BerkeleyDB::DB_NOTFOUND) {
538 $id = ($id || 64) + 1;
539 if ($self->{facemap}->put (id => $id) == 0
540 && $self->{facemap}->put ($hash => $id) == 0) {
541 $txn->txn_commit;
542
543 goto gotid;
544 }
545 }
546 $txn->txn_abort;
547 }
548
549 CFPlus::fatal "maximum number of transaction retries reached - database problems?";
550 }
551
552gotid:
553 $face->{id} = $id; 586 $face->{id} = $id;
554 $self->{map}->set_face ($facenum => $id);
555 $self->{faceid}[$facenum] = $id;#d# 587 $self->{faceid}[$facenum] = $id;
556 588
557 my $face = $self->{tilecache}->get ($id); 589 $self->{map}->set_tileid ($facenum => $id);
558 590
559 if ($face) { 591 CFPlus::DB::get tilecache => $id, $cb;
560 #$self->face_prefetch;
561 $face
562 } else {
563 my $tex = $self->{noface};
564 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
565 undef
566 };
567} 592}
568 593
569sub face_update { 594sub face_update {
570 my ($self, $facenum, $face, $changed) = @_; 595 my ($self, $facenum, $face, $changed) = @_;
571 596
572 $self->{tilecache}->put ($face->{id} => $face->{image}) if $changed; 597 CFPlus::DB::put tilecache => $face->{id} => $face->{image}, sub { }
598 if $changed;
573 599
574 $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});
575} 607}
576 608
577sub set_texture { 609sub set_texture {
578 my ($self, $id, $data) = @_; 610 my ($self, $id, $data) = @_;
579 611
580 $self->{texture}[$id] ||= do { 612 $self->{texture}[$id] = my $tex =
581 my $tex =
582 new_from_image CFPlus::Texture 613 new_from_image CFPlus::Texture
583 $data, minify => 1, mipmap => 1; 614 $data, minify => 1, mipmap => 1;
584 615
585 $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}});
586 $self->{map_widget}->update; 617 $self->{map_widget}->update;
587
588 $tex
589 };
590} 618}
591 619
592sub sound_play { 620sub sound_play {
593 my ($self, $x, $y, $soundnum, $type) = @_; 621 my ($self, $x, $y, $soundnum, $type) = @_;
594 622
604 $LAST_QUERY = $prompt; 632 $LAST_QUERY = $prompt;
605 633
606 $self->{query}-> ($self, $flags, $prompt); 634 $self->{query}-> ($self, $flags, $prompt);
607} 635}
608 636
609sub drawinfo { 637our %NAME_TO_COLOR = (
610 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);
611 652
612 my @color = ( 653our @CF_COLOR = (
613 [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],
614 [1.00, 1.00, 1.00], 655 [1.00, 1.00, 1.00],
615 [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]
616 [1.00, 0.00, 0.00], 657 [1.00, 0.00, 0.00],
617 [1.00, 0.54, 0.00], 658 [1.00, 0.54, 0.00],
618 [0.11, 0.56, 1.00], 659 [0.11, 0.56, 1.00],
619 [0.93, 0.46, 0.00], 660 [0.93, 0.46, 0.00],
620 [0.18, 0.54, 0.34], 661 [0.18, 0.54, 0.34],
621 [0.56, 0.73, 0.56], 662 [0.56, 0.73, 0.56],
622 [0.80, 0.80, 0.80], 663 [0.80, 0.80, 0.80],
623 [0.75, 0.61, 0.20], 664 [0.75, 0.61, 0.20],
624 [0.99, 0.77, 0.26], 665 [0.99, 0.77, 0.26],
625 [0.74, 0.65, 0.41], 666 [0.74, 0.65, 0.41],
626 ); 667);
627 668
669sub msg {
670 my ($self, $color, $type, $text, @extra) = @_;
671
672 # we now weed out all tags we do not support
673 $text =~ s%<(?!/?i>|/?u>|/?b>|fg |/fg>)%&lt;%g;
674 # now all entities
675 $text =~ s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&amp;/g;
676
677 # handle some elements
678 $text =~ s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs;
679 $text =~ s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs;
680
681 if (my $cb = $self->{cb_msg}{$type}) {
682 $_->($self, $color, $type, $text, @extra) for values %$cb;
683 } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) {
684 $type =~ s/-/_/g;
685 $self->{$type} = $text;
686 } else {
628 $self->logprint ("info: ", $text); 687 $self->logprint ("msg: ", $text);
688 return if $color < 0; # negative color == ignore if not understood
629 689
690 my $fg = $CF_COLOR[$color % @CF_COLOR];
691
630 # try to create single paragraphs of multiple lines sent by the server 692 ## try to create single paragraphs of multiple lines sent by the server
693 # no longer neecssary with TRT servers
631 $text =~ s/(?<=\S)\n(?=\w)/ /g; 694 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
632 695
633 $text = CFPlus::asxml $text;
634 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
635 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
636
637 ::message ({ fg => $color[$color], markup => $_ }) 696 ::message ({ fg => $fg, markup => $_ })
638 for split /\n/, $text; 697 for split /\n/, $text;
639 698
640 $self->{statusbox}->add ($text, 699 $self->{statusbox}->add ($text,
641 group => $text, 700 group => $text,
642 fg => $color[$color], 701 fg => $fg,
643 timeout => $color >= 2 ? 180 : 10, 702 timeout => $color >= 2 ? 180 : 10,
644 tooltip_font => $::FONT_FIXED, 703 tooltip_font => $::FONT_FIXED,
645 ); 704 );
646} 705 }
647
648sub drawextinfo {
649 my ($self, $color, $type, $subtype, $message) = @_;
650
651 $self->drawinfo ($color, $message);
652} 706}
653 707
654sub spell_add { 708sub spell_add {
655 my ($self, $spell) = @_; 709 my ($self, $spell) = @_;
656 710
672} 726}
673 727
674sub setup { 728sub setup {
675 my ($self, $setup) = @_; 729 my ($self, $setup) = @_;
676 730
731 $self->{map_widget}->set_tilesize ($self->{tilesize});
677 $::MAP->resize ($self->{mapw}, $self->{maph}); 732 $::MAP->resize ($self->{mapw}, $self->{maph});
678} 733}
679 734
680sub addme_success { 735sub addme_success {
681 my ($self) = @_; 736 my ($self) = @_;
888 $::SERVER_INFO->set_markup ( 943 $::SERVER_INFO->set_markup (
889 "server <tt>$self->{host}:$self->{port}</tt>\n" 944 "server <tt>$self->{host}:$self->{port}</tt>\n"
890 . "protocol version <tt>$self->{version}</tt>\n" 945 . "protocol version <tt>$self->{version}</tt>\n"
891 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 946 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
892 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 947 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
948 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
893 . "editing support $yesno[!!$self->{editor_support}]\n" 949 . "editing support $yesno[!!$self->{editor_support}]\n"
894 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 950 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
951 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
895 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 952 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
896 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 953 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
897 . "map size $self->{mapw}×$self->{maph}\n" 954 . "map size $self->{mapw}×$self->{maph}\n"
898 ); 955 );
899 956
921 978
922 $self->update_server_info; 979 $self->update_server_info;
923 980
924 $self->send_command ("output-sync $::CFG->{output_sync}"); 981 $self->send_command ("output-sync $::CFG->{output_sync}");
925 $self->send_command ("output-count $::CFG->{output_count}"); 982 $self->send_command ("output-count $::CFG->{output_count}");
983 $self->send_command ("output-rate $::CFG->{output_rate}") if $::CFG->{output_rate} > 0;
926 $self->send_command ("pickup $::CFG->{pickup}"); 984 $self->send_command ("pickup $::CFG->{pickup}");
927} 985}
928 986
929sub buildat { 987sub buildat {
930 my ($self, $builditem, $x, $y) = @_; 988 my ($self, $builditem, $x, $y) = @_;
982 kw => { hi => 0, yes => 0, no => 0 }, 1040 kw => { hi => 0, yes => 0, no => 0 },
983 has_close_button => 1, 1041 has_close_button => 1,
984 @_, 1042 @_,
985 ); 1043 );
986 1044
987 Scalar::Util::weaken (my $this = $self); 1045 CFPlus::weaken (my $this = $self);
988 1046
989 $self->connect (delete => sub { $this->destroy; 1 }); 1047 $self->connect (delete => sub { $this->destroy; 1 });
990 1048
991 # better use a pane... 1049 # better use a pane...
992 $self->add (my $hbox = new CFPlus::UI::HBox); 1050 $self->add (my $hbox = new CFPlus::UI::HBox);
1036}; 1094};
1037 1095
1038sub update_options { 1096sub update_options {
1039 my ($self) = @_; 1097 my ($self) = @_;
1040 1098
1041 Scalar::Util::weaken $self; 1099 CFPlus::weaken $self;
1042 1100
1043 $self->{options}->clear; 1101 $self->{options}->clear;
1044 $self->{options}->add ($self->{bye_button}); 1102 $self->{options}->add ($self->{bye_button});
1045 1103
1046 for my $kw (sort keys %{ $self->{kw} }) { 1104 for my $kw (sort keys %{ $self->{kw} }) {
1055} 1113}
1056 1114
1057sub feed { 1115sub feed {
1058 my ($self, $msg) = @_; 1116 my ($self, $msg) = @_;
1059 1117
1060 Scalar::Util::weaken $self; 1118 CFPlus::weaken $self;
1061 1119
1062 if ($msg->{msgtype} eq "reply") { 1120 if ($msg->{msgtype} eq "reply") {
1063 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []}; 1121 $self->{kw}{$_} = 1 for @{$msg->{add_topics} || []};
1064 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []}; 1122 $self->{kw}{$_} = 0 for @{$msg->{del_topics} || []};
1065 1123

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines