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.144 by root, Fri Aug 3 02:20:32 2007 UTC vs.
Revision 1.146 by root, Mon Aug 6 05:06:33 2007 UTC

226} 226}
227 227
228sub logprint { 228sub logprint {
229 my ($self, @a) = @_; 229 my ($self, @a) = @_;
230 230
231 $self->{log_fh} ||= do { 231 CFPlus::DB::logprint "$Crossfire::VARDIR/log.$self->{host}" => (join "", @a), sub { };
232 my $path = "$Crossfire::VARDIR/log.$self->{host}";
233
234 open my $fh, ">>:utf8", $path
235 or die "Couldn't open logfile $path: $!";
236
237 $fh->autoflush (1);
238
239 $fh;
240 };
241
242 my ($sec, $min, $hour, $mday, $mon, $year) = localtime time;
243
244 my $ts = sprintf "%04d-%02d-%02d %02d:%02d:%02d",
245 $year + 1900, $mon + 1, $mday, $hour, $min, $sec;
246
247 print {$self->{log_fh}} "$ts ", @a, "\n";
248} 232}
249 233
250sub _stat_numdiff { 234sub _stat_numdiff {
251 my ($self, $name, $old, $new) = @_; 235 my ($self, $name, $old, $new) = @_;
252 236
560 do { 544 do {
561 $id = pop @{$self->{bg_fetch}} 545 $id = pop @{$self->{bg_fetch}}
562 or return; 546 or return;
563 } while $self->{texture}[$id]; 547 } while $self->{texture}[$id];
564 548
565 CFPlus::DB::get tilecache => $id, sub { 549 CFPlus::DB::exists tilecache => $id, sub {
566 my ($data) = @_; 550 my ($exists) = @_;
567 551
568 return unless $self->{map}; # stop when destroyed 552 return unless $self->{map}; # stop when destroyed
569 553
570 $self->set_texture ($id => $data) 554 $self->have_tile ($id)
571 if defined $data; 555 if $exists;
572 556
573 $self->bg_fetch; 557 $self->bg_fetch;
574 }; 558 };
575} 559}
576 560
744 728
745 if ($face->{type} == 0) { # FT_FACE 729 if ($face->{type} == 0) { # FT_FACE
746 CFPlus::DB::put tilecache => $face->{id} => $face->{data}, sub { } 730 CFPlus::DB::put tilecache => $face->{id} => $face->{data}, sub { }
747 if $changed; 731 if $changed;
748 732
749 $self->set_texture ($face->{id} => delete $face->{data}); 733 $self->have_tile ($face->{id});
750 734
751 } elsif ($face->{type} & 1) { # split metadata 735 } elsif ($face->{type} & 1) { # split metadata
752 my $cb = sub { }; 736 my $cb = sub { };
753 737
754 if ($face->{type} == 3) { # FT_MUSIC 738 if ($face->{type} == 3) { # FT_MUSIC
793 my ($self, $facenum, $face) = @_; 777 my ($self, $facenum, $face) = @_;
794 778
795 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel}); 779 $self->{map}->set_smooth ($facenum, $face->{smoothface}, $face->{smoothlevel});
796} 780}
797 781
798sub set_texture { 782sub have_tile {
799 my ($self, $id, $data) = @_; 783 my ($self, $tile) = @_;
800 784
801 return unless $self->{map}; 785 return unless $self->{map};
802 786
803 $self->{texture}[$id] = my $tex = 787 $self->{texture}[$tile] ||= my $tex =
804 new_from_image CFPlus::Texture 788 new CFPlus::Texture
805 $data, minify => 1, mipmap => 1; 789 tile => $tile, minify => 1, mipmap => 1, delay => 1;
806 790
807 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});
808 $self->{map_widget}->update;
809
810 $_->() for @{(delete $self->{face_cb}{$id}) || []}; 791 $_->() for @{(delete $self->{face_cb}{$tile}) || []};
811} 792}
812 793
813sub connect_face_update { 794sub connect_face_update {
814 my ($self, $id, $cb) = @_; 795 my ($self, $id, $cb) = @_;
815 796

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines