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.96 by root, Fri Apr 6 07:45:35 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
402 407
403 $self->{map}->clear; 408 $self->{map}->clear;
404 delete $self->{map_widget}{magicmap}; 409 delete $self->{map_widget}{magicmap};
405} 410}
406 411
412sub bg_fetch {
413 my ($self) = @_;
414
415 my $id;
416
417 do {
418 $id = pop @{$self->{bg_fetch}}
419 or return;
420 } while $self->{texture}[$id];
421
422 CFPlus::DB::get tilecache => $id, sub {
423 my ($data) = @_;
424
425 return unless $self->{map}; # stop when destroyed
426
427 $self->set_texture ($id => $data)
428 if defined $data;
429
430 $self->bg_fetch;
431 };
432}
407 433
408sub load_map($$$) { 434sub load_map($$$) {
409 my ($self, $hash, $x, $y) = @_; 435 my ($self, $hash, $x, $y) = @_;
410 436
411 CFPlus::DB::get $self->{mapcache} => $hash, sub { 437 CFPlus::DB::get $self->{mapcache} => $hash, sub {
412 my ($data) = @_; 438 my ($data) = @_;
413 439
414 if (defined $data) { 440 if (defined $data) {
415 $data = Compress::LZF::decompress $data; 441 $data = Compress::LZF::decompress $data;
416 #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#
417 for my $id ($self->{map}->set_rect ($x, $y, $data)) {
418 CFPlus::DB::get tilecache => $id, sub {
419 my ($data) = @_;
420 443
421 $self->set_texture ($id => $data) 444 my $inprogress = @{ $self->{bg_fetch} || [] };
422 if defined $data; 445 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data);
423 }; 446 $self->bg_fetch unless $inprogress;
424 }
425 } 447 }
426 }; 448 };
427} 449}
428 450
429# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 451# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
568 if $changed; 590 if $changed;
569 591
570 $self->set_texture ($face->{id} => delete $face->{image}); 592 $self->set_texture ($face->{id} => delete $face->{image});
571} 593}
572 594
595sub smooth_update {
596 my ($self, $facenum, $face) = @_;
597
598 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel});
599}
600
573sub set_texture { 601sub set_texture {
574 my ($self, $id, $data) = @_; 602 my ($self, $id, $data) = @_;
575 603
576 $self->{texture}[$id] ||= do { 604 $self->{texture}[$id] = my $tex =
577 my $tex =
578 new_from_image CFPlus::Texture 605 new_from_image CFPlus::Texture
579 $data, minify => 1, mipmap => 1; 606 $data, minify => 1, mipmap => 1;
580 607
581 $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}});
582 $self->{map_widget}->update; 609 $self->{map_widget}->update;
583
584 $tex
585 };
586} 610}
587 611
588sub sound_play { 612sub sound_play {
589 my ($self, $x, $y, $soundnum, $type) = @_; 613 my ($self, $x, $y, $soundnum, $type) = @_;
590 614

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines