--- deliantra/server/ext/map-random.ext 2008/05/04 14:12:37 1.26 +++ deliantra/server/ext/map-random.ext 2009/11/09 03:08:55 1.37 @@ -57,7 +57,7 @@ } sub clean_random_maps { - my $files = Coro::AIO::aio_readdir $cf::RANDOMDIR + my $files = Coro::AIO::aio_readdirx $cf::RANDOMDIR, IO::AIO::READDIR_STAT_ORDER or return; my $META_TIMEOUT = $cf::CFG{map_random_meta_timeout} || 86400 * 7; @@ -82,16 +82,14 @@ sub find_style_($$) { my ($path, $difficulty) = @_; - my $mapdir = cf::datadir . "/" . cf::mapdir; - my $map; $map = cf::map::find $path - unless aio_stat "$mapdir/$path.map"; + unless aio_stat "$cf::MAPDIR/$path.map"; unless ($map) { # search files and/or dirs - if (my ($dirs, $nondirs) = aio_scandir "$mapdir/$path/", 1) { + if (my ($dirs, $nondirs) = aio_scandir "$cf::MAPDIR/$path/", 1) { my @entries = sort grep s/\.map$//, @$nondirs; if ($difficulty < 0) { @@ -138,7 +136,7 @@ $map->deactivate; } - warn "return $dir,$name,$difficulty => $map\n" if $difficulty >= 0;#d# + #warn "return $dir,$name,$difficulty => $map\n" if $difficulty >= 0;#d# $map } @@ -148,7 +146,7 @@ }; # map generator stresstest, NEVER enable under normal circumstances -if (0) { +if ($ENV{STRESSTEST}) { cf::async { my $seed = 0; while () { @@ -156,10 +154,10 @@ $map->generate_random_map ({ region => "scorn", random_seed => $seed++, - xsize => (int rand 90) + 3, - ysize => (int rand 90) + 3, + xsize => (int rand 100) + 1, + ysize => (int rand 100) + 1, }); -# warn sprintf "%d: %d %d\n", $seed, $map->width, $map->height;#d# + warn sprintf "%d: %dx%d o# %d\n", $seed, $map->width, $map->height, &cf::object::objects_size;#d# $map->destroy; } }; @@ -177,6 +175,26 @@ } }; } + +# save test +if (0) { + cf::async { + # 0.080 + Coro::Timer::sleep 2; + my $map = cf::map::find "/mlab/citydeclouds2"; + $map->load_header; + $map->load; + $map->post_load_original; + my $m=100; + for (1..50) { + my $t=EV::time; + $map->_save_objects ("/tmp/x", cf::IO_HEADER | cf::IO_OBJECTS | cf::IO_UNIQUES); + $t = EV::time-$t; + $m=$t if $m>$t; + warn $m; + } + }; +} 1