ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.514 by root, Mon Apr 12 17:13:36 2010 UTC vs.
Revision 1.518 by root, Fri Apr 16 02:21:26 2010 UTC

2212 $MAP_PREFETCHER->prio (6); 2212 $MAP_PREFETCHER->prio (6);
2213 2213
2214 () 2214 ()
2215} 2215}
2216 2216
2217# common code, used by both ->save and ->swapout
2217sub save { 2218sub _save {
2218 my ($self) = @_; 2219 my ($self) = @_;
2219
2220 my $lock = cf::lock_acquire "map_data:$self->{path}";
2221 2220
2222 $self->{last_save} = $cf::RUNTIME; 2221 $self->{last_save} = $cf::RUNTIME;
2223 2222
2224 return unless $self->dirty; 2223 return unless $self->dirty;
2225 2224
2245 } else { 2244 } else {
2246 $self->_save_objects ($save, cf::IO_HEADER | cf::IO_OBJECTS | cf::IO_UNIQUES); 2245 $self->_save_objects ($save, cf::IO_HEADER | cf::IO_OBJECTS | cf::IO_UNIQUES);
2247 } 2246 }
2248} 2247}
2249 2248
2249sub save {
2250 my ($self) = @_;
2251
2252 my $lock = cf::lock_acquire "map_data:$self->{path}";
2253
2254 $self->_save;
2255}
2256
2250sub swap_out { 2257sub swap_out {
2251 my ($self) = @_; 2258 my ($self) = @_;
2252 2259
2253 # save first because save cedes
2254 $self->save;
2255
2256 my $lock = cf::lock_acquire "map_data:$self->{path}"; 2260 my $lock = cf::lock_acquire "map_data:$self->{path}";
2257 2261
2258 return if $self->players;
2259 return if $self->in_memory != cf::MAP_ACTIVE; 2262 return if $self->in_memory != cf::MAP_ACTIVE;
2260 return if $self->{deny_save}; 2263 return if $self->{deny_save};
2264 return if $self->players;
2261 2265
2262 $self->in_memory (cf::MAP_SWAPPED); 2266 # first deactivate the map and "unlink" it from the core
2263
2264 $self->deactivate; 2267 $self->deactivate;
2265 $_->clear_links_to ($self) for values %cf::MAP; 2268 $_->clear_links_to ($self) for values %cf::MAP;
2269 $self->in_memory (cf::MAP_SWAPPED);
2270
2271 # then atomically save
2272 $self->_save;
2273
2274 # then free the map
2266 $self->clear; 2275 $self->clear;
2267} 2276}
2268 2277
2269sub reset_at { 2278sub reset_at {
2270 my ($self) = @_; 2279 my ($self) = @_;
3543 LOG llevInfo, "Welcome to Deliantra, v" . VERSION; 3552 LOG llevInfo, "Welcome to Deliantra, v" . VERSION;
3544 LOG llevInfo, "Copyright (C) 2005-2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team."; 3553 LOG llevInfo, "Copyright (C) 2005-2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team.";
3545 LOG llevInfo, "Copyright (C) 1994 Mark Wedel."; 3554 LOG llevInfo, "Copyright (C) 1994 Mark Wedel.";
3546 LOG llevInfo, "Copyright (C) 1992 Frank Tore Johansen."; 3555 LOG llevInfo, "Copyright (C) 1992 Frank Tore Johansen.";
3547 3556
3548 cf::init_experience;
3549 cf::init_anim;
3550 cf::init_attackmess;
3551 cf::init_dynamic;
3552
3553 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority 3557 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority
3554 3558
3555 # we must not ever block the main coroutine 3559 # we must not ever block the main coroutine
3556 local $Coro::idle = sub { 3560 local $Coro::idle = sub {
3557 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# 3561 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d#
3562 }; 3566 };
3563 3567
3564 evthread_start IO::AIO::poll_fileno; 3568 evthread_start IO::AIO::poll_fileno;
3565 3569
3566 cf::sync_job { 3570 cf::sync_job {
3571 cf::init_experience;
3572 cf::init_anim;
3573 cf::init_attackmess;
3574 cf::init_dynamic;
3575
3567 cf::load_settings; 3576 cf::load_settings;
3568 cf::load_materials; 3577 cf::load_materials;
3569 3578
3570 reload_resources; 3579 reload_resources;
3571 reload_config; 3580 reload_config;
3587 use POSIX (); 3596 use POSIX ();
3588 POSIX::close delete $ENV{LOCKUTIL_LOCK_FD} if exists $ENV{LOCKUTIL_LOCK_FD}; 3597 POSIX::close delete $ENV{LOCKUTIL_LOCK_FD} if exists $ENV{LOCKUTIL_LOCK_FD};
3589 3598
3590 (pop @POST_INIT)->(0) while @POST_INIT; 3599 (pop @POST_INIT)->(0) while @POST_INIT;
3591 }; 3600 };
3601
3602 cf::object::thawer::errors_are_fatal 0;
3603 warn "parse errors in files are no longer fatal from this point on.\n";
3592 3604
3593 main_loop; 3605 main_loop;
3594} 3606}
3595 3607
3596############################################################################# 3608#############################################################################

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines