… | |
… | |
2171 | |
2171 | |
2172 | { |
2172 | { |
2173 | my $guard = cf::lock_acquire "map_data:$path"; |
2173 | my $guard = cf::lock_acquire "map_data:$path"; |
2174 | |
2174 | |
2175 | return unless $self->valid; |
2175 | return unless $self->valid; |
2176 | return unless $self->in_memory == cf::MAP_SWAPPED; |
2176 | return unless $self->state == cf::MAP_SWAPPED; |
2177 | |
2177 | |
2178 | $self->alloc; |
2178 | $self->alloc; |
2179 | |
2179 | |
2180 | $self->pre_load; |
2180 | $self->pre_load; |
2181 | cf::cede_to_tick; |
2181 | cf::cede_to_tick; |
… | |
… | |
2204 | } else { |
2204 | } else { |
2205 | $self->post_load_original |
2205 | $self->post_load_original |
2206 | if delete $self->{load_original}; |
2206 | if delete $self->{load_original}; |
2207 | } |
2207 | } |
2208 | |
2208 | |
2209 | $self->in_memory (cf::MAP_INACTIVE); |
2209 | $self->state (cf::MAP_INACTIVE); |
2210 | |
2210 | |
2211 | cf::cede_to_tick; |
2211 | cf::cede_to_tick; |
2212 | # now do the right thing for maps |
2212 | # now do the right thing for maps |
2213 | $self->link_multipart_objects; |
2213 | $self->link_multipart_objects; |
2214 | $self->difficulty ($self->estimate_difficulty) |
2214 | $self->difficulty ($self->estimate_difficulty) |
… | |
… | |
2377 | return if $self->players; |
2377 | return if $self->players; |
2378 | |
2378 | |
2379 | # first deactivate the map and "unlink" it from the core |
2379 | # first deactivate the map and "unlink" it from the core |
2380 | $self->deactivate; |
2380 | $self->deactivate; |
2381 | $_->clear_links_to ($self) for values %cf::MAP; |
2381 | $_->clear_links_to ($self) for values %cf::MAP; |
2382 | $self->in_memory (cf::MAP_SWAPPED); |
2382 | $self->state (cf::MAP_SWAPPED); |
2383 | |
2383 | |
2384 | # then atomically save |
2384 | # then atomically save |
2385 | $self->_save; |
2385 | $self->_save; |
2386 | |
2386 | |
2387 | # then free the map |
2387 | # then free the map |
… | |
… | |
2413 | |
2413 | |
2414 | return if $self->players; |
2414 | return if $self->players; |
2415 | |
2415 | |
2416 | cf::trace "resetting map ", $self->path, "\n"; |
2416 | cf::trace "resetting map ", $self->path, "\n"; |
2417 | |
2417 | |
2418 | $self->in_memory (cf::MAP_SWAPPED); |
2418 | $self->state (cf::MAP_SWAPPED); |
2419 | |
2419 | |
2420 | # need to save uniques path |
2420 | # need to save uniques path |
2421 | unless ($self->{deny_save}) { |
2421 | unless ($self->{deny_save}) { |
2422 | my $uniq = $self->uniq_path; utf8::encode $uniq; |
2422 | my $uniq = $self->uniq_path; utf8::encode $uniq; |
2423 | |
2423 | |