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.102 by root, Wed Apr 18 18:16:16 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 %{$arg{setup_req} || {}},
26 }, 26 },
27 ); 27 );
28 28
29 $self->{map_widget}->clr_commands; 29 $self->{map_widget}->clr_commands;
30 30
432} 432}
433 433
434sub load_map($$$) { 434sub load_map($$$) {
435 my ($self, $hash, $x, $y) = @_; 435 my ($self, $hash, $x, $y) = @_;
436 436
437 my $gen = $self->{map_change_gen};
438
437 CFPlus::DB::get $self->{mapcache} => $hash, sub { 439 CFPlus::DB::get $self->{mapcache} => $hash, sub {
440 return unless $gen == $self->{map_change_gen};
441
438 my ($data) = @_; 442 my ($data) = @_;
439 443
440 if (defined $data) { 444 if (defined $data) {
441 $data = Compress::LZF::decompress $data; 445 $data = Compress::LZF::decompress $data;
442 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# 446 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d#
517 521
518 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 522 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
519 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 523 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
520 524
521 } else { 525 } else {
526 my $gen = $self->{map_change_gen};
522 $self->send_mapinfo ("spatial $path$tile", sub { 527 $self->send_mapinfo ("spatial $path$tile", sub {
528 return unless $gen == $self->{map_change_gen};
529
523 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 530 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
524 531
525 return if $mode ne "spatial"; 532 return if $mode ne "spatial";
526 533
527 $x += $self->{map}->ox; 534 $x += $self->{map}->ox;
541 548
542sub map_change { 549sub map_change {
543 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 550 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
544 551
545 $self->flush_map; 552 $self->flush_map;
553
554 ++$self->{map_change_gen};
546 555
547 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 556 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
548 557
549 my $mapmapw = $self->{mapmap}->{w}; 558 my $mapmapw = $self->{mapmap}->{w};
550 my $mapmaph = $self->{mapmap}->{h}; 559 my $mapmaph = $self->{mapmap}->{h};
647 656
648 my $fg = $color[$color % @color]; 657 my $fg = $color[$color % @color];
649 658
650 $self->logprint ("info: ", $text); 659 $self->logprint ("info: ", $text);
651 660
652 # try to create single paragraphs of multiple lines sent by the server 661 ## try to create single paragraphs of multiple lines sent by the server
662 # no longer neecssary with TRT servers
653 $text =~ s/(?<=\S)\n(?=\w)/ /g; 663 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
654 664
655 $text = CFPlus::asxml $text; 665 $text = CFPlus::asxml $text;
656 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 666 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
657 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 667 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
658 668

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines