… | |
… | |
17 | our $TEX_DIALOGUE = new_from_resource DC::Texture |
17 | our $TEX_DIALOGUE = new_from_resource DC::Texture |
18 | "dialogue.png", minify => 1, mipmap => 1; |
18 | "dialogue.png", minify => 1, mipmap => 1; |
19 | |
19 | |
20 | our $TEX_NOFACE = new_from_resource DC::Texture |
20 | our $TEX_NOFACE = new_from_resource DC::Texture |
21 | "noface.png", minify => 1, mipmap => 1; |
21 | "noface.png", minify => 1, mipmap => 1; |
|
|
22 | |
|
|
23 | sub MIN_TEXTURE_UNUSED() { 1 }#d# |
22 | |
24 | |
23 | sub new { |
25 | sub new { |
24 | my ($class, %arg) = @_; |
26 | my ($class, %arg) = @_; |
25 | |
27 | |
26 | my $self = $class->SUPER::new (%arg, |
28 | my $self = $class->SUPER::new (%arg, |
… | |
… | |
90 | |
92 | |
91 | { |
93 | { |
92 | $self->{noface} = my $tex = $TEX_NOFACE; |
94 | $self->{noface} = my $tex = $TEX_NOFACE; |
93 | $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
95 | $self->{map}->set_texture (2, @$tex{qw(name w h s t)}, @{$tex->{minified}}); |
94 | } |
96 | } |
|
|
97 | |
|
|
98 | # $self->{expire_count} = DC::DB::FIRST_TILE_ID; # minimum non-fixed tile id |
|
|
99 | # $self->{expire_w} = EV::timer 1, 1, sub { |
|
|
100 | # my $count = (int @{ $self->{texture} } / MIN_TEXTURE_UNUSED) || 1; |
|
|
101 | # |
|
|
102 | # for ($self->{map}->expire_textures ($self->{expire_count}, $count)) { |
|
|
103 | # warn DC::SvREFCNT $self->{texture}[$_]; |
|
|
104 | # $self->{texture}[$_]->unload; |
|
|
105 | # warn "expire texture $_\n";#d# |
|
|
106 | # } |
|
|
107 | # |
|
|
108 | # ($self->{expire_count} += $count) < @{ $self->{texture} } |
|
|
109 | # or $self->{expire_count} = DC::DB::FIRST_TILE_ID; |
|
|
110 | # warn "count is $count\n";#d# |
|
|
111 | # }; |
95 | |
112 | |
96 | $self->{open_container} = 0; |
113 | $self->{open_container} = 0; |
97 | |
114 | |
98 | # per server |
115 | # per server |
99 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
116 | $self->{mapcache} = "mapcache_$self->{host}_$self->{port}"; |
… | |
… | |
656 | for my $tile (@$missing) { |
673 | for my $tile (@$missing) { |
657 | next if $self->{delay}{$tile}; |
674 | next if $self->{delay}{$tile}; |
658 | |
675 | |
659 | $delay = 1; |
676 | $delay = 1; |
660 | |
677 | |
661 | if (my $tex = $::CONN->{texture}[$tile]) { |
678 | if (my $tex = $self->{texture}[$tile]) { |
662 | $tex->upload; |
679 | $tex->upload; |
663 | } else { |
680 | } else { |
664 | $self->{delay}{$tile} = 1; |
681 | $self->{delay}{$tile} = 1; |
665 | |
682 | |
666 | # we assume the face is in-flight and will eventually come |
683 | # we assume the face is in-flight and will eventually arrive |
667 | push @{$self->{tile_cb}{$tile}}, sub { |
684 | push @{$self->{tile_cb}{$tile}}, sub { |
668 | delete $self->{delay}{$tile}; |
685 | delete $self->{delay}{$tile}; |
669 | $_[0]->upload; |
686 | $_[0]->upload; |
670 | }; |
687 | }; |
671 | } |
688 | } |
672 | } |
689 | } |
673 | |
690 | |
674 | if ($delay) { |
691 | if ($delay) { |
675 | # delay the map drawing a tiny bit in the hope of getting the missing fetched |
692 | # delay the map drawing a tiny bit in the hope of getting the missing tiles fetched |
676 | EV::once undef, 0, 0.03, sub { |
693 | EV::once undef, 0, 0.03, sub { |
677 | $self->{map_widget}->update |
694 | $self->{map_widget}->update |
678 | if $self->{map_widget}; |
695 | if $self->{map_widget}; |
679 | }; |
696 | }; |
680 | } else { |
697 | } else { |