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.97 by root, Fri Apr 6 08:09:43 2007 UTC vs.
Revision 1.99 by root, Tue Apr 10 09:39:48 2007 UTC

17use base 'Crossfire::Protocol::Base'; 17use base 'Crossfire::Protocol::Base';
18 18
19sub new { 19sub new {
20 my $class = shift; 20 my $class = shift;
21 21
22 my $self = $class->SUPER::new (@_, setup_req => { extmap => 1 }); 22 my $self = $class->SUPER::new (@_,
23 setup_req => {
24 extmap => 1,
25 smoothing => 1,
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
415 } while $self->{texture}[$id]; 420 } while $self->{texture}[$id];
416 421
417 CFPlus::DB::get tilecache => $id, sub { 422 CFPlus::DB::get tilecache => $id, sub {
418 my ($data) = @_; 423 my ($data) = @_;
419 424
425 return unless $self->{map}; # stop when destroyed
426
420 $self->set_texture ($id => $data) 427 $self->set_texture ($id => $data)
421 if defined $data; 428 if defined $data;
422 429
423 $self->bg_fetch; 430 $self->bg_fetch;
424 }; 431 };
433 if (defined $data) { 440 if (defined $data) {
434 $data = Compress::LZF::decompress $data; 441 $data = Compress::LZF::decompress $data;
435 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# 442 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d#
436 443
437 my $inprogress = @{ $self->{bg_fetch} || [] }; 444 my $inprogress = @{ $self->{bg_fetch} || [] };
438 push @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); 445 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data);
439 $self->bg_fetch unless $inprogress; 446 $self->bg_fetch unless $inprogress;
440 } 447 }
441 }; 448 };
442} 449}
443 450
583 if $changed; 590 if $changed;
584 591
585 $self->set_texture ($face->{id} => delete $face->{image}); 592 $self->set_texture ($face->{id} => delete $face->{image});
586} 593}
587 594
595sub smooth_update {
596 my ($self, $facenum, $face) = @_;
597
598 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel});
599}
600
588sub set_texture { 601sub set_texture {
589 my ($self, $id, $data) = @_; 602 my ($self, $id, $data) = @_;
590 603
591 $self->{texture}[$id] ||= do { 604 $self->{texture}[$id] = my $tex =
592 my $tex =
593 new_from_image CFPlus::Texture 605 new_from_image CFPlus::Texture
594 $data, minify => 1, mipmap => 1; 606 $data, minify => 1, mipmap => 1;
595 607
596 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 608 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
597 $self->{map_widget}->update; 609 $self->{map_widget}->update;
598
599 $tex
600 };
601} 610}
602 611
603sub sound_play { 612sub sound_play {
604 my ($self, $x, $y, $soundnum, $type) = @_; 613 my ($self, $x, $y, $soundnum, $type) = @_;
605 614

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines