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.98 by root, Fri Apr 6 19:17:25 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 (@_, setup_req => { extmap => 1 }); 22 my $self = $class->SUPER::new (%arg,
23 setup_req => {
24 extmap => 1,
25 %{$arg{setup_req} || {}},
26 },
27 );
23 28
24 $self->{map_widget}->clr_commands; 29 $self->{map_widget}->clr_commands;
25 30
26 my @cmd_help = map { 31 my @cmd_help = map {
27 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x 32 $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x
427} 432}
428 433
429sub load_map($$$) { 434sub load_map($$$) {
430 my ($self, $hash, $x, $y) = @_; 435 my ($self, $hash, $x, $y) = @_;
431 436
437 my $gen = $self->{map_change_gen};
438
432 CFPlus::DB::get $self->{mapcache} => $hash, sub { 439 CFPlus::DB::get $self->{mapcache} => $hash, sub {
440 return unless $gen == $self->{map_change_gen};
441
433 my ($data) = @_; 442 my ($data) = @_;
434 443
435 if (defined $data) { 444 if (defined $data) {
436 $data = Compress::LZF::decompress $data; 445 $data = Compress::LZF::decompress $data;
437 #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#
512 521
513 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags) 522 $self->flood_fill ($block, $gx, $gy, "$path$tile", $hash, $flags)
514 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1; 523 if $x >= $x0 && $x + $w < $x1 && $y >= $y0 && $y + $h < $y1;
515 524
516 } else { 525 } else {
526 my $gen = $self->{map_change_gen};
517 $self->send_mapinfo ("spatial $path$tile", sub { 527 $self->send_mapinfo ("spatial $path$tile", sub {
528 return unless $gen == $self->{map_change_gen};
529
518 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_; 530 my ($mode, $flags, $x, $y, $w, $h, $hash) = @_;
519 531
520 return if $mode ne "spatial"; 532 return if $mode ne "spatial";
521 533
522 $x += $self->{map}->ox; 534 $x += $self->{map}->ox;
536 548
537sub map_change { 549sub map_change {
538 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 550 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
539 551
540 $self->flush_map; 552 $self->flush_map;
553
554 ++$self->{map_change_gen};
541 555
542 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 556 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
543 557
544 my $mapmapw = $self->{mapmap}->{w}; 558 my $mapmapw = $self->{mapmap}->{w};
545 my $mapmaph = $self->{mapmap}->{h}; 559 my $mapmaph = $self->{mapmap}->{h};
583 597
584 CFPlus::DB::put tilecache => $face->{id} => $face->{image}, sub { } 598 CFPlus::DB::put tilecache => $face->{id} => $face->{image}, sub { }
585 if $changed; 599 if $changed;
586 600
587 $self->set_texture ($face->{id} => delete $face->{image}); 601 $self->set_texture ($face->{id} => delete $face->{image});
602}
603
604sub smooth_update {
605 my ($self, $facenum, $face) = @_;
606
607 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel});
588} 608}
589 609
590sub set_texture { 610sub set_texture {
591 my ($self, $id, $data) = @_; 611 my ($self, $id, $data) = @_;
592 612
636 656
637 my $fg = $color[$color % @color]; 657 my $fg = $color[$color % @color];
638 658
639 $self->logprint ("info: ", $text); 659 $self->logprint ("info: ", $text);
640 660
641 # 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
642 $text =~ s/(?<=\S)\n(?=\w)/ /g; 663 #$text =~ s/(?<=\S)\n(?=\w)/ /g;
643 664
644 $text = CFPlus::asxml $text; 665 $text = CFPlus::asxml $text;
645 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g; 666 $text =~ s/\[b\](.*?)\[\/b\]/<b>\1<\/b>/g;
646 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g; 667 $text =~ s/\[color=(.*?)\](.*?)\[\/color\]/<span foreground='\1'>\2<\/span>/g;
647 668

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines