--- deliantra/server/ext/map-world.ext 2007/02/13 19:25:44 1.13 +++ deliantra/server/ext/map-world.ext 2007/04/17 20:41:15 1.21 @@ -43,13 +43,10 @@ or die "convert: $!"; binmode $fh; - binmode $fh; $size * 3 == read $fh, my $data, $size * 3 or die "$path.png, expected $size rgb triplets: $!"; - $data =~ s{(...)}{ - $plt{$1} or die "$path.png: color not in palette: #" . unpack "H*", $1 - }sge; + cf::_quantise $data, [map "$_$plt{$_}", keys %plt]; binmode STDOUT; syswrite STDOUT, $data; @@ -69,7 +66,7 @@ sub load_gridmap($) { my ($path) = @_; - if (! -e "/tmp/xxxx.gridmap") { +# if (! -e "/tmp/xxxx.gridmap") { 0 < aio_load "$path/gridmap.meta", my $map or cf::cleanup "$path/gridmap.meta: $!\n"; @@ -81,12 +78,12 @@ ($map->{arc_data}, $map->{arc_plt}) = load_indexed "$path/gridmap.arch", $size; ($map->{reg_data}, $map->{reg_plt}) = load_indexed "$path/gridmap.regn", $size; - Storable::nstore $map, "/tmp/xxxx.gridmap";#d# +# Storable::nstore $map, "/tmp/xxxx.gridmap" if 0;#d# $map - } else { - Storable::retrieve "/tmp/xxxx.gridmap"; - } +# } else { +# Storable::retrieve "/tmp/xxxx.gridmap"; +# } } # this is contorted, but likely the correct way to acquire the lock :) @@ -120,14 +117,14 @@ $self->name ("'The World' at +$x+$y"); $self->msg ("worldmap dynamically created by map-world extension"); $self->outdoor (1); - $self->default_region (undef); + $self->default_region (cf::region::find "wilderness"); $self->tile_path (0, sprintf "/world/world_%03d_%03d", $x, $y - 1) if $y > 0; $self->tile_path (1, sprintf "/world/world_%03d_%03d", $x + 1, $y) if $x < 999; $self->tile_path (2, sprintf "/world/world_%03d_%03d", $x, $y + 1) if $y < 999; $self->tile_path (3, sprintf "/world/world_%03d_%03d", $x - 1, $y) if $x > 0; - $self->{load_path} = sprintf "%s/%s/world-overlay/world_%03d_%03d", cf::datadir, cf::mapdir, $x, $y + $self->{load_path} = sprintf "%s/%s/world-overlay/world_%03d_%03d.map", cf::datadir, cf::mapdir, $x, $y if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129; 1 @@ -136,16 +133,8 @@ sub fill { my ($self) = @_; - for my $X (0 .. $WORLD->{tile_w} - 1) { - Coro::cede; - for my $Y (0 .. $WORLD->{tile_h} - 1) { - my $ob = cf::object::new "deep_sea"; - $ob->flag (cf::FLAG_NO_MAP_SAVE, 1); - $self->insert ($ob, $X, $Y, undef, cf::INS_ABOVE_FLOOR_ONLY); - } - } - $self->set_object_flag (cf::FLAG_NO_MAP_SAVE, 1); - $self->default_region (cf::region::find "panthalassia"); + $self->add_underlay ("\x00" x ($WORLD->{tile_w} * $WORLD->{tile_h}), 0, $WORLD->{tile_w}, $WORLD->{arc_plt}); + $self->default_region (cf::region::find $WORLD->{reg_plt}[0]); } sub load { @@ -172,21 +161,9 @@ my $top = ($y - 100) * $WORLD->{tile_h} * $stride + ($x - 100) * $WORLD->{tile_w}; - my $reg; - - for my $Y (0 .. $WORLD->{tile_h} - 1) { - Coro::cede; - my $row = substr $WORLD->{arc_data}, $top + $Y * $stride, $WORLD->{tile_w}; - $reg .= substr $WORLD->{reg_data}, $top + $Y * $stride, $WORLD->{tile_w}; - for my $X (0 .. $WORLD->{tile_w} - 1) { - next if grep $_->flag (cf::FLAG_IS_FLOOR), $self->at ($X, $Y); - my $ob = cf::object::new $WORLD->{arc_plt}[ord substr $row, $X]; - $ob->flag (cf::FLAG_NO_MAP_SAVE, 1); - $self->insert ($ob, $X, $Y, undef, cf::INS_ABOVE_FLOOR_ONLY); - } - } + $self->add_underlay ($WORLD->{arc_data}, $top, $stride, $WORLD->{arc_plt}); + $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); - $self->set_regiondata ($reg, $WORLD->{reg_plt}); } else { $self->fill; }