ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.53 by root, Sun Aug 19 09:27:08 2007 UTC vs.
Revision 1.54 by root, Sun Aug 19 10:28:52 2007 UTC

170 if ($w % $T || $h % $T) { 170 if ($w % $T || $h % $T) {
171 warn "$path: weird png size ($w $h), skipping.\n"; 171 warn "$path: weird png size ($w $h), skipping.\n";
172 next; 172 next;
173 } 173 }
174 174
175 (my $base = $stem) =~ s/^.*\///;
176
177 my $fi = $FACEINFO{$base};
178 unless ($fi) {
179 warn "$path: <$base> not referenced by any archetype, skipping.\n";
180 next;
181 }
182
183 my $arc = $FACEINFO{$base}{arc}
184 or die "FATAL: internal error, cannot continue";
185
175 unless ($path =~ /~$/) { 186 unless ($path =~ /~$/) {
176 # possibly enlarge 187 # possibly enlarge
177 if (0 > aio_stat "$stem.64x64.png") { 188 if (0 > aio_stat "$stem.64x64.png") {
178 my $other = "$stem.64x64.png~"; 189 my $other = "$stem.64x64.png~";
179 190
180 if (0 > aio_lstat $other or (-M _) > (-M $path)) { 191 if (0 > aio_lstat $other or (-M _) > (-M $path)) {
181 fork_sub { 192 fork_sub {
182 my $CROP; 193 my $CROP;
183 my $SRC = "png:\Q$path\E"; 194 my $SRC = "png:\Q$path\E";
184 195
185 # check if this is a wall. ultra-ugly. ultra-ultra-ugly. 196 my $is_floor = $arc->{is_floor};
197 my $is_wall = 0;
198
199 my ($wall_pfx, $wall_dir, $wall_sfx);
200
201 if (
202 !$is_floor
203 && !$arc->{alive}
204 && $arc->{no_pass}
186 if ($path =~ /^(.*\/wall\/.*_)([0-9A-F])(\.x11.*\.png)$/) { 205 && $path =~ /^(.*_)([0-9A-F])(\.x11.*\.png)$/
206 ) {
187 my ($pfx, $dir, $sfx) = ($1, hex $2, $3); 207 ($wall_pfx, $wall_dir, $wall_sfx) = ($1, hex $2, $3);
188 #check for 0..F images to be sure(?) this is a wall 208
189 unless (grep { !-e sprintf "%s%X%s", $pfx, $_, $sfx } 0..15) { 209 unless (grep { !-e sprintf "%s%X%s", $wall_pfx, $_, $wall_sfx } 0..15) {
210 $is_wall = 1;
211 }
212 }
213
214 if ($is_wall || $is_floor) {
190 # add a 4px border and add other images around it 215 # add a 4px border and add other images around it
191 $CROP = "-shave 8x8 +repage"; 216 $CROP = "-shave 8x8 +repage";
192 217
193 $w += 8; 218 $w += 8;
194 $h += 8; 219 $h += 8;
195 220
196 $SRC = "-size ${w}x${h} xc:transparent"; 221 $SRC = "-size ${w}x${h} xc:transparent";
197 $SRC .= " png:\Q$path\E -geometry +4+4 -composite"; 222 $SRC .= " png:\Q$path\E -geometry +4+4 -composite";
198 223
199 # 8 surrounding images 224 # 8 surrounding images
200 for ( 225 for (
201 # x y b r0 r1 226 # x y b r0 r1
202 [-1, -1, 0, 6], 227 [-1, -1, 0, 6],
203 [ 0, -1, 1, 10, 14], 228 [ 0, -1, 1, 10, 14],
204 [+1, -1, 0, 12], 229 [+1, -1, 0, 12],
205 230
206 [-1, 0, 8, 5, 7], 231 [-1, 0, 8, 5, 7],
207 # 232 #
208 [+1, 0, 2, 5, 13], 233 [+1, 0, 2, 5, 13],
209 234
210 [-1, +1, 0, 3], 235 [-1, +1, 0, 3],
211 [ 0, +1, 4, 10, 11], 236 [ 0, +1, 4, 10, 11],
212 [+1, +1, 0, 9], 237 [+1, +1, 0, 9],
213 ) { 238 ) {
214 my ($x, $y, $d, $r0, $r1) = @$_; 239 my ($x, $y, $d, $r0, $r1) = @$_;
240
241 my $tile = $is_floor ? $path
242 : $is_wall ? sprintf "%s%X%s", $wall_pfx, ($wall_dir & $d) ? $r1 : $r0, $wall_sfx
243 : die;
244
215 $SRC .= sprintf " png:%s%X%s -geometry %+d%+d -composite", 245 $SRC .= sprintf " png:%s -geometry %+d%+d -composite",
216 "\Q$pfx", 246 "\Q$tile",
217 ($dir & $d) ? $r1 : $r0,
218 "\Q$sfx",
219 $x * ($w - 8) + 4, 247 $x * ($w - 8) + 4,
220 $y * ($h - 8) + 4; 248 $y * ($h - 8) + 4;
221 }
222 } 249 }
223 } 250 }
224 251
225 system "convert -depth 8 $SRC rgba:-" 252 system "convert -depth 8 $SRC rgba:-"
226 . "| $exec_prefix/bin/cfhq2xa $w $h 0" 253 . "| $exec_prefix/bin/cfhq2xa $w $h 0"
410 $info->{visibility} = $visibility if defined $visibility; 437 $info->{visibility} = $visibility if defined $visibility;
411 $info->{magicmap} = $magicmap if defined $magicmap; 438 $info->{magicmap} = $magicmap if defined $magicmap;
412 } 439 }
413 440
414 if (my $smooth = delete $o->{smoothface}) { 441 if (my $smooth = delete $o->{smoothface}) {
415 my %kv =split /\s+/, $smooth; 442 my %kv = split /\s+/, $smooth;
416 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support 443 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
417 while (my ($face, $smooth) = each %kv) { 444 while (my ($face, $smooth) = each %kv) {
445 $FACEINFO{$smooth}{arc} = $o;
446
418 $FACEINFO{$face}{smooth} = $smooth; 447 $FACEINFO{$face}{smooth} = $smooth;
419 $FACEINFO{$face}{smoothlevel} = $level; 448 $FACEINFO{$face}{smoothlevel} = $level;
420 } 449 }
421 } 450 }
422 } 451 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines