ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/util/png2world
Revision: 1.8
Committed: Sat Sep 16 13:59:46 2006 UTC (17 years, 8 months ago) by elmex
Branch: MAIN
Changes since 1.7: +1 -0 lines
Log Message:
added small_stones

File Contents

# Content
1 #!/opt/bin/perl
2
3 use Crossfire::Map;
4 use Storable;
5 use POSIX;
6
7 use Gtk2 -init;
8
9 { open my $fh, "<:raw", "mask.bin" or die; sysread $fh, $mask, 1500*1500*4 or die }
10 { open my $fh, "<:raw", "type.bin" or die; sysread $fh, $type, 1500*1500*4 or die }
11
12 my %type = (
13 deep_sea => "#006",
14 sea => "#008",
15 shallow_sea => "#00a",
16
17 beach => "#aa0",
18 dunes => "#bb0",
19 desert => "#cc0",
20 steppe => "#880",
21 steppelight => "#dd7",
22 small_stones => "#eeb",
23
24 marsh => "#0f8",
25 grass => "#0f0",
26 grassmedium => "#0e0",
27 grassbrown => "#851",
28 grassdark => "#274",
29 desert => "#cc0",
30
31 darkforest => "#040",
32 evergreens => "#0a0",
33 woods => "#080",
34
35 swamp => "#660",
36 deep_swamp => "#440",
37
38 jungle_1 => "#084",
39
40 hills_rocky => "#aa8",
41 treed_hills => "#6a4",
42 hills => "#aa4",
43 mountain => "#ccc",
44 mountain4 => "#cdd",
45 mountain5 => "#ddd",
46
47 cobblestones => "#ea2",
48 );
49
50 for my $k (keys %type) {
51 my $v = join "", map chr, (map $_*255/15, map hex, split //, substr $type{$k}, 1), 255;
52 $color{$v} = $k;
53 }
54
55 my $maps = Storable::retrieve "worldmaps.pst";
56
57 for my $X (100..129) {
58 print "$X\n";#d#
59 for my $Y (100..129) {
60 my $map = delete $maps->[$X][$Y];
61 {
62 my $X = ($X - 100) * 50;
63 my $Y = ($Y - 100) * 50;
64 for my $x (0..49) {
65 for my $y (0..49) {
66 my $ofs = (($Y + $y)* 1500 + $X + $x) * 4;
67
68 my $mask = substr $mask, $ofs, 4;
69 my $type = substr $type, $ofs, 4;
70
71 next if $mask eq "\xff\x00\x00\xff";
72
73 if (my $k = $color{$type}) {
74 $map->{map}[$x][$y] = [{
75 _name => "$k",
76 }];
77 }
78 }
79 }
80 }
81 if ((my $pid = fork)) {
82 push @pids, $pid;
83 waitpid shift @pids, 0 if @pids > 3;
84 } else {
85 eval { $map->write_file ("../maps/world/world_$X\_$Y") };
86 warn $@ if $@;
87 POSIX::_exit 0;
88 }
89 }
90 }
91