--- deliantra/server/ext/map-world.ext 2007/04/21 11:55:36 1.25 +++ deliantra/server/ext/map-world.ext 2007/09/19 21:56:30 1.31 @@ -1,4 +1,4 @@ -#! perl # OPTIONAL +#! perl # optional # optional plug-in to speed up worldmap rendering by dynamically # generating it out of an image @@ -6,6 +6,8 @@ # - saves temporary space (only overlay stuff needs to be saved) # - might get reused as a generic tiled map +cf::map->register (qr{^/world/world_(\d\d\d)_(\d\d\d)$}, 100); + use Coro::Handle; use Coro::AIO; @@ -88,13 +90,12 @@ cf::sync_job { my $guard = cf::lock_acquire "ext::world_gridmap"; cf::async_ext { + $Coro::current->{desc} = "worldmap loader"; reload; undef $guard; }; }; -cf::map->register (qr{^/world/world_(\d\d\d)_(\d\d\d)$}, 100); - sub wxwy { $_[0]->path =~ m{/world/world_(\d\d\d)_(\d\d\d)$} ? ($1, $2) @@ -121,8 +122,10 @@ $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/world-overlay/world_%03d_%03d.map", $cf::MAPDIR, $x, $y - if $x >= 100 && $x <= 129 && $y >= 100 && $y <= 129; + my $overlay = sprintf "%s/world/world_%03d_%03d.map", $cf::MAPDIR, $x, $y; + + $self->{load_path} = $overlay + unless Coro::AIO::aio_stat $overlay; $self->{need_create_treasure} = 1; @@ -145,33 +148,33 @@ $self->alloc; $self->fill; $self->in_memory (cf::MAP_IN_MEMORY); + $self->activate; } } sub post_load { my ($self) = @_; - my $guard = cf::lock_acquire "ext::world_gridmap"; + { + my $guard = cf::lock_acquire "ext::world_gridmap"; - my ($x, $y) = $self->wxwy; + my ($x, $y) = $self->wxwy; - if ($x >= 100 && $x <= 129 && $y >= 100 && $y <= 129) { - my $stride = $WORLD->{grid_w} * $WORLD->{tile_w}; - my $top = ($y - 100) * $WORLD->{tile_h} * $stride - + ($x - 100) * $WORLD->{tile_w}; + if ($x >= 100 && $x <= 129 && $y >= 100 && $y <= 129) { + my $stride = $WORLD->{grid_w} * $WORLD->{tile_w}; + my $top = ($y - 100) * $WORLD->{tile_h} * $stride + + ($x - 100) * $WORLD->{tile_w}; - $self->add_underlay ($WORLD->{arc_data}, $top, $stride, $WORLD->{arc_plt}); - $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); + $self->add_underlay ($WORLD->{arc_data}, $top, $stride, $WORLD->{arc_plt}); + $self->set_regiondata ($WORLD->{reg_data}, $top, $stride, $WORLD->{reg_plt}); - } else { - $self->fill; + } else { + $self->fill; + } } - if (delete $self->{need_create_treasure}) { - $self->create_region_treasure; - # TODO: temporary? hack to fix multipart objects because treausres only create the head - $self->link_multipart_objects; - } + $self->create_region_treasure + if delete $self->{need_create_treasure}; } 1