Revision: | 1.1.1.1 (vendor branch) |
Committed: | Sat Feb 4 23:56:12 2006 UTC (18 years, 10 months ago) by root |
Content type: | text/plain |
Branch: | UPSTREAM, MAIN |
CVS Tags: | post_fixaltar, last_stable, post_fixaltar2, rel-2_82, rel-2_81, rel-2_80, pre_coinconvert, UPSTREAM_2006_03_15, rel-3_0, rel-2_6, rel-2_7, rel-2_4, rel-2_5, rel-2_2, rel-2_0, rel-2_1, rel-2_72, rel-2_73, rel-2_71, rel-2_76, rel-2_77, rel-2_74, rel-2_75, rel-2_54, rel-2_55, rel-2_56, rel-2_79, UPSTREAM_2006_02_01, rel-2_53, pre_material_cfarch_normalize_run, rel-2_32, pre_fixconverter, post_coinconvert, pre_fixaltar2, pre_map_rename, UPSTREAM_2006_02_22, rel-2_90, rel-2_92, rel-2_93, rel-2_78, post_fixconverter, pre_fixaltar, rel-2_61, rel-2_43, rel-2_42, rel-2_41, HEAD |
Changes since 1.1: | +0 -0 lines |
Log Message: | Initial Import |
# | Content |
---|---|
1 | #!/usr/bin/perl |
2 | # This script takes a bunch of world image files and combines them |
3 | # into one large image. This should be run from the directory |
4 | # where all the images are. |
5 | # Note that this takes a while to run. Probably pretty proportional |
6 | # to the the size of the target image. |
7 | # This is somewhat hacked for my usage - it presumes you run this |
8 | # from the top level of the maps directory (eg, contains world, scorn, |
9 | # etc directories). This is smart enough to regen the image files |
10 | # that may be missing/out of date. |
11 | |
12 | $DEST_WIDTH=3000; |
13 | $DEST_HEIGHT=3000; |
14 | |
15 | $NUM_X=30; |
16 | $NUM_Y=30; |
17 | |
18 | $START_X=100; |
19 | $START_Y=100; |
20 | |
21 | $TILE_WIDTH = $DEST_WIDTH/$NUM_X; |
22 | $TILE_HEIGHT = $DEST_HEIGHT/$NUM_Y; |
23 | # This is the command to run the editor. Really, it can be anything that |
24 | # outputs a .png file. The %I and %O are substituted with actul |
25 | # path names. |
26 | $CFEDITOR="cd /export/home/crossfire/CFJavaEditor; java -Xmx128mb -classpath class/:lib/png.jar:lib/visualtek.jar cfeditor.CFJavaEditor -infile %I -outfile %O > /dev/null"; |
27 | |
28 | die ("No images directory - exiting\n") if (! -d "./images"); |
29 | use Cwd; |
30 | $cwd = cwd(); |
31 | |
32 | |
33 | # If we already have a combined image, then we only need to paste |
34 | # the new bits onto it, saving a bunch of time |
35 | if (! -f "images/combine.ppm") { |
36 | system("ppmmake \\#000 $DEST_WIDTH $DEST_HEIGHT > /tmp/tmp.ppm"); |
37 | $first_run=1; |
38 | print "Creating images for the first time.\n"; |
39 | } else { |
40 | system("cp images/combine.ppm /tmp/tmp.ppm"); |
41 | $first_run=0; |
42 | } |
43 | |
44 | print "Processing."; |
45 | for ($x=0; $x<$NUM_X; $x++) { |
46 | for ($y=0; $y<$NUM_Y; $y++) { |
47 | print "."; |
48 | $dx = $x + $START_X; |
49 | $dy = $y + $START_Y; |
50 | |
51 | # These time values are the reverse in how you'd normally think about them - they |
52 | # are the time (in days) since the fiel was last modified. Thus, a file that hasn't |
53 | # been modified in a long time has a high value, a file modified recently has |
54 | # a low level. |
55 | $time1 = -M "images\/world_$dx\_$dy.png"; |
56 | $time2 = -M "world\/world_$dx\_$dy"; |
57 | if ($time1 > $time2) { |
58 | $cmd = $CFEDITOR; |
59 | $cmd =~ s#%I#$cwd/world/world_$dx\_$dy#; |
60 | $cmd =~ s#%O#$cwd/images/world_$dx\_$dy.png#; |
61 | system($cmd); |
62 | system("pngtopnm images/world_$dx\_$dy.png | pnmscale -xysize $TILE_WIDTH $TILE_HEIGHT > /tmp/ppm.tmp"); |
63 | $sx = $x * $TILE_WIDTH; |
64 | $sy = $y * $TILE_HEIGHT; |
65 | system("pnmpaste /tmp/ppm.tmp $sx $sy /tmp/tmp.ppm > /tmp/tmp.ppm1"); |
66 | unlink("/tmp/tmp.ppm"); |
67 | rename("/tmp/tmp.ppm1", "/tmp/tmp.ppm"); |
68 | } |
69 | } |
70 | } |
71 | system("mv /tmp/tmp.ppm images/combine.ppm"); |
72 | print "\n"; |