--- deliantra/server/lib/cf.pm 2007/03/06 03:06:00 1.222 +++ deliantra/server/lib/cf.pm 2007/03/11 02:12:44 1.223 @@ -45,6 +45,7 @@ our %EXT_CORO = (); # coroutines bound to extensions our %EXT_MAP = (); # pluggable maps +our $RELOAD; # number of reloads so far our @EVENT; our $LIBDIR = datadir . "/ext"; @@ -2268,9 +2269,38 @@ ############################################################################# # the server's init and main functions -sub init_resources { +sub load_faces { + my $path = sprintf "%s/faces", cf::datadir; + + warn "loading faces from $path\n"; + + my $faces; + 0 < aio_load $path, $faces + or die "$path: $!"; + + Coro::cede; + $faces = Storable::thaw $faces; + Coro::cede; + + while (my ($face, $info) = each %$faces) { + my $idx = (cf::face::find $face) || cf::face::alloc $face; + cf::face::set $idx, $info->{visibility}, $info->{magicmap}; + cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; + Coro::cede; + } + + 1 +} + +sub reload_resources { load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir or die "unable to load regions file\n";#d# + load_faces + or die "unable to load faces\n";#d# +} + +sub init { + reload_resources; } sub cfg_load { @@ -2294,10 +2324,6 @@ } } -sub init { - init_resources; -} - sub main { # we must not ever block the main coroutine local $Coro::idle = sub { @@ -2408,6 +2434,8 @@ warn "iterate..."; } + ++$RELOAD; + warn "cancelling all extension coros"; $_->cancel for values %EXT_CORO; %EXT_CORO = (); @@ -2481,7 +2509,7 @@ reattach $_ for values %PLAYER; warn "loading reloadable resources"; - init_resources; + reload_resources; warn "leaving sync_job";