--- deliantra/server/utils/cfutil.in 2007/08/19 09:27:08 1.53 +++ deliantra/server/utils/cfutil.in 2007/08/19 10:28:52 1.54 @@ -172,6 +172,17 @@ next; } + (my $base = $stem) =~ s/^.*\///; + + my $fi = $FACEINFO{$base}; + unless ($fi) { + warn "$path: <$base> not referenced by any archetype, skipping.\n"; + next; + } + + my $arc = $FACEINFO{$base}{arc} + or die "FATAL: internal error, cannot continue"; + unless ($path =~ /~$/) { # possibly enlarge if (0 > aio_stat "$stem.64x64.png") { @@ -182,43 +193,59 @@ my $CROP; my $SRC = "png:\Q$path\E"; - # check if this is a wall. ultra-ugly. ultra-ultra-ugly. - if ($path =~ /^(.*\/wall\/.*_)([0-9A-F])(\.x11.*\.png)$/) { - my ($pfx, $dir, $sfx) = ($1, hex $2, $3); - #check for 0..F images to be sure(?) this is a wall - unless (grep { !-e sprintf "%s%X%s", $pfx, $_, $sfx } 0..15) { - # add a 4px border and add other images around it - $CROP = "-shave 8x8 +repage"; - - $w += 8; - $h += 8; - - $SRC = "-size ${w}x${h} xc:transparent"; - $SRC .= " png:\Q$path\E -geometry +4+4 -composite"; - - # 8 surrounding images - for ( - # x y b r0 r1 - [-1, -1, 0, 6], - [ 0, -1, 1, 10, 14], - [+1, -1, 0, 12], - - [-1, 0, 8, 5, 7], - # - [+1, 0, 2, 5, 13], - - [-1, +1, 0, 3], - [ 0, +1, 4, 10, 11], - [+1, +1, 0, 9], - ) { - my ($x, $y, $d, $r0, $r1) = @$_; - $SRC .= sprintf " png:%s%X%s -geometry %+d%+d -composite", - "\Q$pfx", - ($dir & $d) ? $r1 : $r0, - "\Q$sfx", - $x * ($w - 8) + 4, - $y * ($h - 8) + 4; - } + my $is_floor = $arc->{is_floor}; + my $is_wall = 0; + + my ($wall_pfx, $wall_dir, $wall_sfx); + + if ( + !$is_floor + && !$arc->{alive} + && $arc->{no_pass} + && $path =~ /^(.*_)([0-9A-F])(\.x11.*\.png)$/ + ) { + ($wall_pfx, $wall_dir, $wall_sfx) = ($1, hex $2, $3); + + unless (grep { !-e sprintf "%s%X%s", $wall_pfx, $_, $wall_sfx } 0..15) { + $is_wall = 1; + } + } + + if ($is_wall || $is_floor) { + # add a 4px border and add other images around it + $CROP = "-shave 8x8 +repage"; + + $w += 8; + $h += 8; + + $SRC = "-size ${w}x${h} xc:transparent"; + $SRC .= " png:\Q$path\E -geometry +4+4 -composite"; + + # 8 surrounding images + for ( + # x y b r0 r1 + [-1, -1, 0, 6], + [ 0, -1, 1, 10, 14], + [+1, -1, 0, 12], + + [-1, 0, 8, 5, 7], + # + [+1, 0, 2, 5, 13], + + [-1, +1, 0, 3], + [ 0, +1, 4, 10, 11], + [+1, +1, 0, 9], + ) { + my ($x, $y, $d, $r0, $r1) = @$_; + + my $tile = $is_floor ? $path + : $is_wall ? sprintf "%s%X%s", $wall_pfx, ($wall_dir & $d) ? $r1 : $r0, $wall_sfx + : die; + + $SRC .= sprintf " png:%s -geometry %+d%+d -composite", + "\Q$tile", + $x * ($w - 8) + 4, + $y * ($h - 8) + 4; } } @@ -412,9 +439,11 @@ } if (my $smooth = delete $o->{smoothface}) { - my %kv =split /\s+/, $smooth; + my %kv = split /\s+/, $smooth; my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support while (my ($face, $smooth) = each %kv) { + $FACEINFO{$smooth}{arc} = $o; + $FACEINFO{$face}{smooth} = $smooth; $FACEINFO{$face}{smoothlevel} = $level; }