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.99 by root, Tue Apr 10 09:39:48 2007 UTC vs.
Revision 1.104 by root, Mon Apr 23 19:22:24 2007 UTC

15use Crossfire::Protocol::Base 0.95; 15use Crossfire::Protocol::Base 0.95;
16 16
17use base 'Crossfire::Protocol::Base'; 17use base 'Crossfire::Protocol::Base';
18 18
19sub new { 19sub new {
20 my $class = shift; 20 my ($class, %arg) = @_;
21 21
22 my $self = $class->SUPER::new (@_, 22 my $self = $class->SUPER::new (%arg,
23 setup_req => { 23 setup_req => {
24 extmap => 1, 24 extmap => 1,
25 smoothing => 1, 25 excmd => 1,
26 %{$arg{setup_req} || {}},
26 }, 27 },
27 ); 28 );
28 29
29 $self->{map_widget}->clr_commands; 30 $self->{map_widget}->clr_commands;
30 31
432} 433}
433 434
434sub load_map($$$) { 435sub load_map($$$) {
435 my ($self, $hash, $x, $y) = @_; 436 my ($self, $hash, $x, $y) = @_;
436 437
438 my $gen = $self->{map_change_gen};
439
437 CFPlus::DB::get $self->{mapcache} => $hash, sub { 440 CFPlus::DB::get $self->{mapcache} => $hash, sub {
441 return unless $gen == $self->{map_change_gen};
442
438 my ($data) = @_; 443 my ($data) = @_;
439 444
440 if (defined $data) { 445 if (defined $data) {
441 $data = Compress::LZF::decompress $data; 446 $data = Compress::LZF::decompress $data;
442 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# 447 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d#
517 522
518 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 523 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
519 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 524 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
520 525
521 } else { 526 } else {
527 my $gen = $self->{map_change_gen};
522 $self->send_mapinfo ("spatial $path$tile", sub { 528 $self->send_mapinfo ("spatial $path$tile", sub {
529 return unless $gen == $self->{map_change_gen};
530
523 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 531 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
524 532
525 return if $mode ne "spatial"; 533 return if $mode ne "spatial";
526 534
527 $x += $self->{map}->ox; 535 $x += $self->{map}->ox;
541 549
542sub map_change { 550sub map_change {
543 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 551 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
544 552
545 $self->flush_map; 553 $self->flush_map;
554
555 ++$self->{map_change_gen};
546 556
547 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 557 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
548 558
549 my $mapmapw = $self->{mapmap}->{w}; 559 my $mapmapw = $self->{mapmap}->{w};
550 my $mapmaph = $self->{mapmap}->{h}; 560 my $mapmaph = $self->{mapmap}->{h};
624 $LAST_QUERY = $prompt; 634 $LAST_QUERY = $prompt;
625 635
626 $self->{query}-> ($self, $flags, $prompt); 636 $self->{query}-> ($self, $flags, $prompt);
627} 637}
628 638
639our @CF_COLOR = (
640 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
641 [1.00, 1.00, 1.00],
642 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
643 [1.00, 0.00, 0.00],
644 [1.00, 0.54, 0.00],
645 [0.11, 0.56, 1.00],
646 [0.93, 0.46, 0.00],
647 [0.18, 0.54, 0.34],
648 [0.56, 0.73, 0.56],
649 [0.80, 0.80, 0.80],
650 [0.75, 0.61, 0.20],
651 [0.99, 0.77, 0.26],
652 [0.74, 0.65, 0.41],
653);
654
629sub drawinfo { 655sub drawinfo {
630 my ($self, $color, $text) = @_; 656 my ($self, $color, $text) = @_;
631 657
632 my @color = ( 658 my $fg = $CF_COLOR[$color % @CF_COLOR];
633 [1.00, 1.00, 1.00], #[0.00, 0.00, 0.00],
634 [1.00, 1.00, 1.00],
635 [0.50, 0.50, 1.00], #[0.00, 0.00, 0.55]
636 [1.00, 0.00, 0.00],
637 [1.00, 0.54, 0.00],
638 [0.11, 0.56, 1.00],
639 [0.93, 0.46, 0.00],
640 [0.18, 0.54, 0.34],
641 [0.56, 0.73, 0.56],
642 [0.80, 0.80, 0.80],
643 [0.75, 0.61, 0.20],
644 [0.99, 0.77, 0.26],
645 [0.74, 0.65, 0.41],
646 );
647
648 my $fg = $color[$color % @color];
649 659
650 $self->logprint ("info: ", $text); 660 $self->logprint ("info: ", $text);
651 661
652 # try to create single paragraphs of multiple lines sent by the server 662 ## try to create single paragraphs of multiple lines sent by the server
663 # no longer neecssary with TRT servers
653 $text =~ s/(?<=\S)\n(?=\w)/ /g; 664 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
654 665
655 $text = CFPlus::asxml $text; 666 $text = CFPlus::asxml $text;
656 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 667 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
657 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 668 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
658 669
911 $::SERVER_INFO->set_markup ( 922 $::SERVER_INFO->set_markup (
912 "server <tt>$self->{host}:$self->{port}</tt>\n" 923 "server <tt>$self->{host}:$self->{port}</tt>\n"
913 . "protocol version <tt>$self->{version}</tt>\n" 924 . "protocol version <tt>$self->{version}</tt>\n"
914 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n" 925 . "minimap support $yesno[$self->{setup}{mapinfocmd} > 0]\n"
915 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n" 926 . "extended command support $yesno[$self->{setup}{extcmd} > 0]\n"
927 . "examine command support $yesno[$self->{setup}{excmd} > 0]\n"
916 . "editing support $yesno[!!$self->{editor_support}]\n" 928 . "editing support $yesno[!!$self->{editor_support}]\n"
917 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" 929 . "map attributes $yesno[$self->{setup}{extmap} > 0]\n"
930 . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n"
918 . "cfplus support $yesno[$self->{cfplus_ext} > 0]" 931 . "cfplus support $yesno[$self->{cfplus_ext} > 0]"
919 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" 932 . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n"
920 . "map size $self->{mapw}×$self->{maph}\n" 933 . "map size $self->{mapw}×$self->{maph}\n"
921 ); 934 );
922 935

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines