ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/util/png2overlay
Revision: 1.3
Committed: Tue Dec 12 16:59:35 2006 UTC (17 years, 6 months ago) by root
Branch: MAIN
Changes since 1.2: +2 -1 lines
Log Message:
*** empty log message ***

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 for my $k (keys %type) {
13 my $v = join "", map chr, (map $_*255/15, map hex, split //, substr $type{$k}, 1), 255;
14 $color{$v} = $k;
15 }
16
17 my %natural = (
18 deep_sea => 1,
19 sea => 1,
20 shallow_sea => 1,
21
22 beach => 1,
23 desert => 1,
24 brush => 1,
25 steppe => 1,
26
27 marsh => 1,
28 grassbrown => 1,
29 grassmedium => 1,
30 grassdark => 1,
31 grass => 1,
32
33 darkforest => 1,
34 evergreens => 1,
35 evergreen => 1,
36 tree => 1,
37 tree1 => 1,
38 tree2 => 1,
39 tree3 => 1,
40 tree4 => 1,
41 tree5 => 1,
42 tree6 => 1,
43 forestsparse=> 1,
44 woods => 1,
45 woods_2 => 1,
46 woods_3 => 1,
47
48 swamp => 1,
49 deep_swamp => 1,
50
51 jungle_1 => 1,
52 jungle_2 => 1,
53 jungle_3 => 1,
54
55 wasteland => 1,
56
57 hills_rocky => 1,
58 hills => 1,
59 treed_hills => 1,
60 mountain => 1,
61 mountain_2 => 1,
62 mountain2 => 1,
63 mountain3 => 1,
64 mountain4 => 1,
65 mountain5 => 1,
66 s_mountain => 1,
67
68 snow => 1,
69 drifts => 1,
70 flagstone => 1,
71 istone => 1,
72 );
73
74 my $maps = Storable::retrieve "worldmaps.pst";
75
76 for my $X (100..129) {
77 print "$X\n";#d#
78 for my $Y (100..129) {
79 my $map = delete $maps->[$X][$Y];
80 Storable::nstore $map, "pst/$X,$Y";
81 {
82 my $X = ($X - 100) * 50;
83 my $Y = ($Y - 100) * 50;
84 for my $x (0..49) {
85 for my $y (0..49) {
86 my $ofs = (($Y + $y)* 1500 + $X + $x) * 4;
87
88 my $mask = substr $mask, $ofs, 4;
89 my $type = substr $type, $ofs, 4;
90
91 # only remove something if we have a worldmap replacement
92 next if $type eq "\xff\xff\xff\xff";
93
94 # mask means: protect unnaturals from overwriting
95 if ($mask eq "\xff\x00\x00\xff") {
96 $map->{map}[$x][$y] = [
97 grep !$natural{$_->{_name}}, @{ $map->{map}[$x][$y] || [] }
98 ];
99 } else {
100 delete $map->{map}[$x][$y];
101 }
102 }
103 }
104 }
105 if ((my $pid = fork)) {
106 push @pids, $pid;
107 waitpid shift @pids, 0 if @pids >= 1;
108 } else {
109 eval { $map->write_file ("../maps/world-overlay/world_$X\_$Y") };
110 warn $@ if $@;
111 POSIX::_exit 0;
112 }
113 }
114 }
115
116 POSIX::_exit 0;
117