--- deliantra/Deliantra-Client/DC/MapWidget.pm 2009/12/21 03:30:23 1.157 +++ deliantra/Deliantra-Client/DC/MapWidget.pm 2010/04/03 02:58:25 1.162 @@ -1,7 +1,6 @@ package DC::MapWidget; -use strict; -use utf8; +use common::sense; use List::Util qw(min max); @@ -12,6 +11,11 @@ our @ISA = DC::UI::Base::; +our @TEX_HIDDEN = map { + new_from_resource DC::Texture # MUST be POT + "hidden-$_.png", mipmap => 1, wrap => 1 + } 0, 1, 2; + my $magicmap_tex = new_from_resource DC::Texture "magicmap.png", mipmap => 1, wrap => 0, internalformat => GL_ALPHA; @@ -211,8 +215,8 @@ # \&editor_invoke, # ]; - for my $type (qw(test name)) { - $::CONN->{editor_support}{type} ne $type + for my $type (@{ $::CONN->{editor_support}{servertypes} }) { + $::CONN->{editor_support}{servertype} ne $type or next; my $server = $::CONN->{editor_support}{"${type}server"} or next; @@ -404,8 +408,7 @@ $self->{sdy} += $dy * $self->{tilesize}; # save old fow texture, if applicable - $self->{last_fow_texture} = $self->{fow_texture} - if $::CFG->{smooth_transitions}; + $self->{prev_fow_texture} = $::CFG->{smooth_transitions} && $self->{fow_texture}; $self->{lfdx} = $dx; $self->{lfdy} = $dy; $self->{lmdx} = $self->{dx}; @@ -492,6 +495,7 @@ my $dy = $self->{dy} = DC::ceil 0.5 * ($::MAP->h - $sh) - $sy; if ($::CFG->{fow_enable}) { + # draw_fow_texture REQUIRES the fow texture to stay the same size. my ($w, $h, $data) = $::MAP->fow_texture ($dx, $dy, $sw, $sh); $self->{fow_texture} = new DC::Texture @@ -519,28 +523,27 @@ glScale $self->{tilesize}, $self->{tilesize}; if (my $tex = $self->{fow_texture}) { - if ($DC::OpenGL::GL_MULTITEX && $self->{last_fow_texture}) {#d# + my @prev_fow_params; + + if ($DC::OpenGL::GL_MULTITEX && $self->{prev_fow_texture}) { my $d1 = DC::distance $self->{sdx}, $self->{sdy}; my $d2 = (DC::distance $self->{lfdx}, $self->{lfdy}) * $tilesize; if ($d1 * $d2) { - DC::Texture::draw_fow_texture - $::CFG->{fow_intensity}, - @{$self->{fow_texture}}{qw(name s t w h)}, + @prev_fow_params = ( (min 1, $d1 / $d2), $self->{lmdx} - $dx - $self->{lfdx}, $self->{lmdy} - $dy - $self->{lfdy}, - @{$self->{last_fow_texture}}{qw(name s t w h)}; - } else { - delete $self->{last_fow_texture}; + @{$self->{prev_fow_texture}}{qw(name data)} + ); } } - unless ($self->{last_fow_texture}) { - DC::Texture::draw_fow_texture - $::CFG->{fow_intensity}, - @{$self->{fow_texture}}{qw(name s t w h)}; - } + DC::Texture::draw_fow_texture + $::CFG->{fow_intensity}, + $TEX_HIDDEN[$::CFG->{fow_texture}]{name}, + @{$self->{fow_texture}}{qw(name data s t w h)}, + @prev_fow_params; } if ($self->{magicmap}) { @@ -558,6 +561,9 @@ glEndList; } } else { + delete $self->{last_fow_texture}; + delete $self->{fow_texture}; + glDeleteList delete $self->{list} if $self->{list}; } @@ -603,8 +609,7 @@ package DC::MapWidget::MapMap; -use strict; -use utf8; +use common::sense; our @ISA = DC::UI::Base::; @@ -708,7 +713,7 @@ package DC::MapWidget::Command; -use strict; +use common::sense; use DC::OpenGL;