--- deliantra/server/lib/cf.pm 2007/02/12 01:25:55 1.209 +++ deliantra/server/lib/cf.pm 2007/02/12 01:32:49 1.210 @@ -1611,9 +1611,18 @@ warn "resetting map ", $self->path;#d# + $self->in_memory (cf::MAP_SWAPPED); + + # need to save uniques path + unless ($self->{deny_save}) { + my $uniq = $self->uniq_path; utf8::encode $uniq; + + $self->_save_objects ($uniq, cf::IO_UNIQUES) + if $uniq; + } + delete $cf::MAP{$self->path}; - $self->in_memory (cf::MAP_SWAPPED); $self->clear; $_->clear_links_to ($self) for values %cf::MAP; @@ -2199,32 +2208,34 @@ our $DB; -unless ($DB) { - $DB = BDB::db_create $DB_ENV; +sub db_init { + unless ($DB) { + $DB = BDB::db_create $DB_ENV; - cf::sync_job { - eval { - $DB->set_flags (BDB::CHKSUM); + cf::sync_job { + eval { + $DB->set_flags (BDB::CHKSUM); - BDB::db_open $DB, undef, "db", undef, BDB::BTREE, - BDB::CREATE | BDB::AUTO_COMMIT, 0666; - cf::cleanup "db_open(db): $!" if $!; + BDB::db_open $DB, undef, "db", undef, BDB::BTREE, + BDB::CREATE | BDB::AUTO_COMMIT, 0666; + cf::cleanup "db_open(db): $!" if $!; + }; + cf::cleanup "db_open(db): $@" if $@; }; - cf::cleanup "db_open(db): $@" if $@; - }; - my $path = cf::localdir . "/database.pst"; - if (stat $path) { - cf::sync_job { - my $pst = Storable::retrieve $path; + my $path = cf::localdir . "/database.pst"; + if (stat $path) { + cf::sync_job { + my $pst = Storable::retrieve $path; - cf::db_put (board => data => $pst->{board}); - cf::db_put (guildrules => data => $pst->{guildrules}); - cf::db_put (rent => balance => $pst->{rent}{balance}); - BDB::db_env_txn_checkpoint $DB_ENV; + cf::db_put (board => data => $pst->{board}); + cf::db_put (guildrules => data => $pst->{guildrules}); + cf::db_put (rent => balance => $pst->{rent}{balance}); + BDB::db_env_txn_checkpoint $DB_ENV; - unlink $path; - }; + unlink $path; + }; + } } } @@ -2287,6 +2298,7 @@ }; cfg_load; + db_init; load_extensions; $TICK_WATCHER->start;