--- deliantra/server/ext/map-world.ext 2007/02/12 19:57:34 1.12 +++ deliantra/server/ext/map-world.ext 2007/02/13 19:25:44 1.13 @@ -133,6 +133,21 @@ 1 } +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"); +} + sub load { my ($self) = @_; @@ -140,18 +155,7 @@ $self->SUPER::load; } else { $self->alloc; - - 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); - } - } - $self->set_object_flag (cf::FLAG_NO_MAP_SAVE, 1); - $self->default_region (cf::region::find "panthalassia"); - + $self->fill; $self->in_memory (cf::MAP_IN_MEMORY); } } @@ -163,28 +167,29 @@ my ($x, $y) = $self->wxwy; - return - unless $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}; - my $reg; + 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); + 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->set_regiondata ($reg, $WORLD->{reg_plt}); + $self->set_regiondata ($reg, $WORLD->{reg_plt}); + } else { + $self->fill; + } } 1