… | |
… | |
1947 | } |
1947 | } |
1948 | |
1948 | |
1949 | sub do_load_sync { |
1949 | sub do_load_sync { |
1950 | my ($map) = @_; |
1950 | my ($map) = @_; |
1951 | |
1951 | |
|
|
1952 | cf::LOG cf::llevDebug | cf::logBacktrace, "do_load_sync" |
|
|
1953 | if $Coro::current == $Coro::main; |
|
|
1954 | |
1952 | cf::sync_job { $map->load }; |
1955 | cf::sync_job { $map->load }; |
1953 | } |
1956 | } |
1954 | |
1957 | |
1955 | our %MAP_PREFETCH; |
1958 | our %MAP_PREFETCH; |
1956 | our $MAP_PREFETCHER = undef; |
1959 | our $MAP_PREFETCHER = undef; |
1957 | |
1960 | |
1958 | sub find_async { |
1961 | sub find_async { |
1959 | my ($path, $origin) = @_; |
1962 | my ($path, $origin, $load) = @_; |
1960 | |
1963 | |
1961 | $path = normalise $path, $origin && $origin->{path}; |
1964 | $path = normalise $path, $origin && $origin->{path}; |
1962 | |
1965 | |
1963 | if (my $map = $cf::MAP{$path}) { |
1966 | if (my $map = $cf::MAP{$path}) { |
1964 | return $map if $map->in_memory == cf::MAP_IN_MEMORY; |
1967 | return $map if !$load || $map->in_memory == cf::MAP_IN_MEMORY; |
1965 | } |
1968 | } |
1966 | |
1969 | |
1967 | undef $MAP_PREFETCH{$path}; |
1970 | $MAP_PREFETCH{$path} |= $load; |
|
|
1971 | |
1968 | $MAP_PREFETCHER ||= cf::async { |
1972 | $MAP_PREFETCHER ||= cf::async { |
1969 | while (%MAP_PREFETCH) { |
1973 | while (%MAP_PREFETCH) { |
1970 | for my $path (keys %MAP_PREFETCH) { |
1974 | while (my ($k, $v) = each %MAP_PREFETCH) { |
1971 | if (my $map = find $path) { |
1975 | if (my $map = find $k) { |
1972 | $map->load; |
1976 | $map->load if $v; |
1973 | } |
1977 | } |
1974 | |
1978 | |
1975 | delete $MAP_PREFETCH{$path}; |
1979 | delete $MAP_PREFETCH{$k}; |
1976 | } |
1980 | } |
1977 | } |
1981 | } |
1978 | undef $MAP_PREFETCHER; |
1982 | undef $MAP_PREFETCHER; |
1979 | }; |
1983 | }; |
1980 | $MAP_PREFETCHER->prio (6); |
1984 | $MAP_PREFETCHER->prio (6); |
… | |
… | |
2728 | |
2732 | |
2729 | The following functions and methods are available within a safe environment: |
2733 | The following functions and methods are available within a safe environment: |
2730 | |
2734 | |
2731 | cf::object |
2735 | cf::object |
2732 | contr pay_amount pay_player map x y force_find force_add |
2736 | contr pay_amount pay_player map x y force_find force_add |
2733 | insert remove name archname title slaying race |
2737 | insert remove name archname title slaying race decrease_ob_nr |
2734 | |
2738 | |
2735 | cf::object::player |
2739 | cf::object::player |
2736 | player |
2740 | player |
2737 | |
2741 | |
2738 | cf::player |
2742 | cf::player |
… | |
… | |
2743 | |
2747 | |
2744 | =cut |
2748 | =cut |
2745 | |
2749 | |
2746 | for ( |
2750 | for ( |
2747 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
2751 | ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y |
2748 | insert remove inv name archname title slaying race)], |
2752 | insert remove inv name archname title slaying race |
|
|
2753 | decrease_ob_nr)], |
2749 | ["cf::object::player" => qw(player)], |
2754 | ["cf::object::player" => qw(player)], |
2750 | ["cf::player" => qw(peaceful)], |
2755 | ["cf::player" => qw(peaceful)], |
2751 | ["cf::map" => qw(trigger)], |
2756 | ["cf::map" => qw(trigger)], |
2752 | ) { |
2757 | ) { |
2753 | no strict 'refs'; |
2758 | no strict 'refs'; |