… | |
… | |
80 | # called by the random map generator |
80 | # called by the random map generator |
81 | sub find_style_; |
81 | sub find_style_; |
82 | sub find_style_($$) { |
82 | sub find_style_($$) { |
83 | my ($path, $difficulty) = @_; |
83 | my ($path, $difficulty) = @_; |
84 | |
84 | |
85 | my $mapdir = cf::datadir . "/" . cf::mapdir; |
|
|
86 | |
|
|
87 | my $map; |
85 | my $map; |
88 | |
86 | |
89 | $map = cf::map::find $path |
87 | $map = cf::map::find $path |
90 | unless aio_stat "$mapdir/$path.map"; |
88 | unless aio_stat "$cf::MAPDIR/$path.map"; |
91 | |
89 | |
92 | unless ($map) { |
90 | unless ($map) { |
93 | # search files and/or dirs |
91 | # search files and/or dirs |
94 | if (my ($dirs, $nondirs) = aio_scandir "$mapdir/$path/", 1) { |
92 | if (my ($dirs, $nondirs) = aio_scandir "$cf::MAPDIR/$path/", 1) { |
95 | my @entries = sort grep s/\.map$//, @$nondirs; |
93 | my @entries = sort grep s/\.map$//, @$nondirs; |
96 | |
94 | |
97 | if ($difficulty < 0) { |
95 | if ($difficulty < 0) { |
98 | # pick a fully random map, but only a map, do not recurse |
96 | # pick a fully random map, but only a map, do not recurse |
99 | $map = cf::map::find "$path/$entries[cf::rmg_rndm scalar @entries]" |
97 | $map = cf::map::find "$path/$entries[cf::rmg_rndm scalar @entries]" |