… | |
… | |
1861 | sub generate_random_map { |
1861 | sub generate_random_map { |
1862 | my ($self, $rmp) = @_; |
1862 | my ($self, $rmp) = @_; |
1863 | |
1863 | |
1864 | my $lock = cf::lock_acquire "generate_random_map"; # the random map generator is NOT reentrant ATM |
1864 | my $lock = cf::lock_acquire "generate_random_map"; # the random map generator is NOT reentrant ATM |
1865 | |
1865 | |
1866 | # mit "rum" bekleckern, nicht |
|
|
1867 | $self->_create_random_map ( |
1866 | $self->_create_random_map ($rmp); |
1868 | $rmp->{wallstyle}, $rmp->{wall_name}, $rmp->{floorstyle}, $rmp->{monsterstyle}, |
|
|
1869 | $rmp->{treasurestyle}, $rmp->{layoutstyle}, $rmp->{doorstyle}, $rmp->{decorstyle}, $rmp->{miningstyle}, |
|
|
1870 | $rmp->{origin_map}, $rmp->{final_map}, $rmp->{exitstyle}, $rmp->{this_map}, |
|
|
1871 | $rmp->{exit_on_final_map}, |
|
|
1872 | $rmp->{xsize}, $rmp->{ysize}, |
|
|
1873 | $rmp->{expand2x}, $rmp->{layoutoptions1}, $rmp->{layoutoptions2}, $rmp->{layoutoptions3}, |
|
|
1874 | $rmp->{symmetry}, $rmp->{difficulty}, $rmp->{difficulty_given}, $rmp->{difficulty_increase}, |
|
|
1875 | $rmp->{dungeon_level}, $rmp->{dungeon_depth}, $rmp->{decoroptions}, $rmp->{orientation}, |
|
|
1876 | $rmp->{origin_y}, $rmp->{origin_x}, $rmp->{random_seed}, $rmp->{total_map_hp}, |
|
|
1877 | $rmp->{map_layout_style}, $rmp->{treasureoptions}, $rmp->{symmetry_used}, |
|
|
1878 | (cf::region::find $rmp->{region}), $rmp->{custom} |
|
|
1879 | ) |
|
|
1880 | } |
1867 | } |
1881 | |
1868 | |
1882 | =item cf::map->register ($regex, $prio) |
1869 | =item cf::map->register ($regex, $prio) |
1883 | |
1870 | |
1884 | Register a handler for the map path matching the given regex at the |
1871 | Register a handler for the map path matching the given regex at the |
… | |
… | |
1935 | $base =~ s{[^/]+/?$}{}; |
1922 | $base =~ s{[^/]+/?$}{}; |
1936 | $path = "$base/$path"; |
1923 | $path = "$base/$path"; |
1937 | } |
1924 | } |
1938 | |
1925 | |
1939 | for ($path) { |
1926 | for ($path) { |
1940 | redo if s{//}{/}; |
|
|
1941 | redo if s{/\.?/}{/}; |
1927 | redo if s{/\.?/}{/}; |
1942 | redo if s{/[^/]+/\.\./}{/}; |
1928 | redo if s{/[^/]+/\.\./}{/}; |
1943 | } |
1929 | } |
1944 | |
1930 | |
1945 | $path |
1931 | $path |
… | |
… | |
2187 | |
2173 | |
2188 | $self->in_memory (cf::MAP_ACTIVE); |
2174 | $self->in_memory (cf::MAP_ACTIVE); |
2189 | } |
2175 | } |
2190 | |
2176 | |
2191 | $self->post_load; |
2177 | $self->post_load; |
|
|
2178 | |
|
|
2179 | 1 |
2192 | } |
2180 | } |
2193 | |
2181 | |
2194 | # customize the map for a given player, i.e. |
2182 | # customize the map for a given player, i.e. |
2195 | # return the _real_ map. used by e.g. per-player |
2183 | # return the _real_ map. used by e.g. per-player |
2196 | # maps to change the path to ~playername/mappath |
2184 | # maps to change the path to ~playername/mappath |
… | |
… | |
3438 | |
3426 | |
3439 | cf::face::set_visibility $idx, $info->{visibility}; |
3427 | cf::face::set_visibility $idx, $info->{visibility}; |
3440 | cf::face::set_magicmap $idx, $info->{magicmap}; |
3428 | cf::face::set_magicmap $idx, $info->{magicmap}; |
3441 | cf::face::set_data $idx, 0, $info->{data32}, $info->{hash32}; |
3429 | cf::face::set_data $idx, 0, $info->{data32}, $info->{hash32}; |
3442 | cf::face::set_data $idx, 1, $info->{data64}, $info->{hash64}; |
3430 | cf::face::set_data $idx, 1, $info->{data64}, $info->{hash64}; |
|
|
3431 | cf::face::set_data $idx, 2, $info->{glyph} , $info->{glyph} ; |
3443 | |
3432 | |
3444 | cf::cede_to_tick; |
3433 | cf::cede_to_tick; |
3445 | } |
3434 | } |
3446 | |
3435 | |
3447 | while (my ($face, $info) = each %$faces) { |
3436 | while (my ($face, $info) = each %$faces) { |
… | |
… | |
4150 | IO::AIO::min_parallel 8; |
4139 | IO::AIO::min_parallel 8; |
4151 | IO::AIO::max_poll_time $TICK * 0.1; |
4140 | IO::AIO::max_poll_time $TICK * 0.1; |
4152 | undef $AnyEvent::AIO::WATCHER; |
4141 | undef $AnyEvent::AIO::WATCHER; |
4153 | } |
4142 | } |
4154 | |
4143 | |
4155 | my $_log_backtrace; |
4144 | our $_log_backtrace; |
|
|
4145 | our $_log_backtrace_last; |
4156 | |
4146 | |
4157 | sub _log_backtrace { |
4147 | sub _log_backtrace { |
4158 | my ($msg, @addr) = @_; |
4148 | my ($msg, @addr) = @_; |
4159 | |
4149 | |
4160 | $msg =~ s/\n//; |
4150 | $msg =~ s/\n$//; |
4161 | |
4151 | |
|
|
4152 | if ($_log_backtrace_last eq $msg) { |
|
|
4153 | LOG llevInfo, "[ABT] $msg\n"; |
|
|
4154 | LOG llevInfo, "[ABT] [duplicate, suppressed]\n"; |
4162 | # limit the # of concurrent backtraces |
4155 | # limit the # of concurrent backtraces |
4163 | if ($_log_backtrace < 2) { |
4156 | } elsif ($_log_backtrace < 2) { |
|
|
4157 | $_log_backtrace_last = $msg; |
4164 | ++$_log_backtrace; |
4158 | ++$_log_backtrace; |
4165 | my $perl_bt = Carp::longmess $msg; |
4159 | my $perl_bt = Carp::longmess $msg; |
4166 | async { |
4160 | async { |
4167 | $Coro::current->{desc} = "abt $msg"; |
4161 | $Coro::current->{desc} = "abt $msg"; |
4168 | |
4162 | |
… | |
… | |
4188 | LOG llevInfo, "[ABT] $_\n" for @bt; |
4182 | LOG llevInfo, "[ABT] $_\n" for @bt; |
4189 | --$_log_backtrace; |
4183 | --$_log_backtrace; |
4190 | }; |
4184 | }; |
4191 | } else { |
4185 | } else { |
4192 | LOG llevInfo, "[ABT] $msg\n"; |
4186 | LOG llevInfo, "[ABT] $msg\n"; |
4193 | LOG llevInfo, "[ABT] [suppressed]\n"; |
4187 | LOG llevInfo, "[ABT] [overload, suppressed]\n"; |
4194 | } |
4188 | } |
4195 | } |
4189 | } |
4196 | |
4190 | |
4197 | # load additional modules |
4191 | # load additional modules |
4198 | require "cf/$_.pm" for @EXTRA_MODULES; |
4192 | require "cf/$_.pm" for @EXTRA_MODULES; |