ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/map-world.ext
(Generate patch)

Comparing deliantra/server/ext/map-world.ext (file contents):
Revision 1.18 by root, Sat Feb 17 02:34:45 2007 UTC vs.
Revision 1.21 by root, Tue Apr 17 20:41:15 2007 UTC

41 eval { 41 eval {
42 open my $fh, "convert \Q$path.png\E -depth 8 rgb:- |" 42 open my $fh, "convert \Q$path.png\E -depth 8 rgb:- |"
43 or die "convert: $!"; 43 or die "convert: $!";
44 binmode $fh; 44 binmode $fh;
45 45
46 binmode $fh;
47 $size * 3 == read $fh, my $data, $size * 3 46 $size * 3 == read $fh, my $data, $size * 3
48 or die "$path.png, expected $size rgb triplets: $!"; 47 or die "$path.png, expected $size rgb triplets: $!";
49 48
50 $data =~ s{(...)}{ 49 cf::_quantise $data, [map "$_$plt{$_}", keys %plt];
51 $plt{$1} or die "$path.png: color not in palette: #" . unpack "H*", $1
52 }sge;
53 50
54 binmode STDOUT; 51 binmode STDOUT;
55 syswrite STDOUT, $data; 52 syswrite STDOUT, $data;
56 }; 53 };
57 warn $@ if $@; 54 warn $@ if $@;
67} 64}
68 65
69sub load_gridmap($) { 66sub load_gridmap($) {
70 my ($path) = @_; 67 my ($path) = @_;
71 68
72 if (! -e "/tmp/xxxx.gridmap") { 69# if (! -e "/tmp/xxxx.gridmap") {
73 0 < aio_load "$path/gridmap.meta", my $map 70 0 < aio_load "$path/gridmap.meta", my $map
74 or cf::cleanup "$path/gridmap.meta: $!\n"; 71 or cf::cleanup "$path/gridmap.meta: $!\n";
75 72
76 $map = cf::from_json $map; 73 $map = cf::from_json $map;
77 74
79 or cf::cleanup "$path/gridmap.meta: empty gridmap?"; 76 or cf::cleanup "$path/gridmap.meta: empty gridmap?";
80 77
81 ($map->{arc_data}, $map->{arc_plt}) = load_indexed "$path/gridmap.arch", $size; 78 ($map->{arc_data}, $map->{arc_plt}) = load_indexed "$path/gridmap.arch", $size;
82 ($map->{reg_data}, $map->{reg_plt}) = load_indexed "$path/gridmap.regn", $size; 79 ($map->{reg_data}, $map->{reg_plt}) = load_indexed "$path/gridmap.regn", $size;
83 80
84 Storable::nstore $map, "/tmp/xxxx.gridmap" if 0;#d# 81# Storable::nstore $map, "/tmp/xxxx.gridmap" if 0;#d#
85 82
86 $map 83 $map
87 } else { 84# } else {
88 Storable::retrieve "/tmp/xxxx.gridmap"; 85# Storable::retrieve "/tmp/xxxx.gridmap";
89 } 86# }
90} 87}
91 88
92# this is contorted, but likely the correct way to acquire the lock :) 89# this is contorted, but likely the correct way to acquire the lock :)
93cf::sync_job { 90cf::sync_job {
94 my $guard = cf::lock_acquire "ext::world_gridmap"; 91 my $guard = cf::lock_acquire "ext::world_gridmap";
118 $self->height ($WORLD->{tile_h}); 115 $self->height ($WORLD->{tile_h});
119 116
120 $self->name ("'The World' at +$x+$y"); 117 $self->name ("'The World' at +$x+$y");
121 $self->msg ("worldmap dynamically created by map-world extension"); 118 $self->msg ("worldmap dynamically created by map-world extension");
122 $self->outdoor (1); 119 $self->outdoor (1);
123 $self->default_region (undef); 120 $self->default_region (cf::region::find "wilderness");
124 121
125 $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0; 122 $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0;
126 $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999; 123 $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999;
127 $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999; 124 $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999;
128 $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0; 125 $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines