… | |
… | |
187 | @safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable'; |
187 | @safe::cf::global::ISA = @cf::global::ISA = 'cf::attachable'; |
188 | @safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable'; |
188 | @safe::cf::object::ISA = @cf::object::ISA = 'cf::attachable'; |
189 | @safe::cf::player::ISA = @cf::player::ISA = 'cf::attachable'; |
189 | @safe::cf::player::ISA = @cf::player::ISA = 'cf::attachable'; |
190 | @safe::cf::client::ISA = @cf::client::ISA = 'cf::attachable'; |
190 | @safe::cf::client::ISA = @cf::client::ISA = 'cf::attachable'; |
191 | @safe::cf::map::ISA = @cf::map::ISA = 'cf::attachable'; |
191 | @safe::cf::map::ISA = @cf::map::ISA = 'cf::attachable'; |
|
|
192 | @safe::cf::arch::ISA = @cf::arch::ISA = 'cf::object'; |
192 | @safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object'; |
193 | @safe::cf::object::player::ISA = @cf::object::player::ISA = 'cf::object'; # not really true (yet) |
193 | |
194 | |
194 | # we bless all objects into (empty) derived classes to force a method lookup |
195 | # we bless all objects into (empty) derived classes to force a method lookup |
195 | # within the Safe compartment. |
196 | # within the Safe compartment. |
196 | for my $pkg (qw( |
197 | for my $pkg (qw( |
197 | cf::global cf::attachable |
198 | cf::global cf::attachable |
… | |
… | |
395 | my $runtime = "$LOCALDIR/runtime"; |
396 | my $runtime = "$LOCALDIR/runtime"; |
396 | |
397 | |
397 | # first touch the runtime file to show we are still running: |
398 | # first touch the runtime file to show we are still running: |
398 | # the fsync below can take a very very long time. |
399 | # the fsync below can take a very very long time. |
399 | |
400 | |
400 | if (my $fh = aio_open $runtime, O_WRONLY, 0) { |
401 | IO::AIO::aio_utime $runtime, undef, undef; |
401 | utime undef, undef, $fh; |
|
|
402 | } |
|
|
403 | |
402 | |
404 | my $guard = cf::lock_acquire "write_runtime"; |
403 | my $guard = cf::lock_acquire "write_runtime"; |
405 | |
404 | |
406 | my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 |
405 | my $fh = aio_open "$runtime~", O_WRONLY | O_CREAT, 0644 |
407 | or return; |
406 | or return; |
… | |
… | |
416 | # always fsync - this file is important |
415 | # always fsync - this file is important |
417 | aio_fsync $fh |
416 | aio_fsync $fh |
418 | and return; |
417 | and return; |
419 | |
418 | |
420 | # touch it again to show we are up-to-date |
419 | # touch it again to show we are up-to-date |
421 | utime undef, undef, $fh; |
420 | aio_utime $fh, undef, undef; |
422 | |
421 | |
423 | close $fh |
422 | close $fh |
424 | or return; |
423 | or return; |
425 | |
424 | |
426 | aio_rename "$runtime~", $runtime |
425 | aio_rename "$runtime~", $runtime |
427 | and return; |
426 | and return; |
428 | |
427 | |
429 | warn "runtime file written.\n";#d# |
428 | warn "runtime file written.\n"; |
430 | |
429 | |
431 | 1 |
430 | 1 |
432 | } |
431 | } |
433 | |
432 | |
434 | =item cf::datalog type => key => value, ... |
433 | =item cf::datalog type => key => value, ... |
… | |
… | |
874 | or return; |
873 | or return; |
875 | $av = eval { (Storable::thaw $av)->{objs} }; |
874 | $av = eval { (Storable::thaw $av)->{objs} }; |
876 | } |
875 | } |
877 | |
876 | |
878 | warn sprintf "loading %s (%d)\n", |
877 | warn sprintf "loading %s (%d)\n", |
879 | $filename, length $data, scalar @{$av || []};#d# |
878 | $filename, length $data, scalar @{$av || []}; |
880 | return ($data, $av); |
879 | return ($data, $av); |
881 | } |
880 | } |
882 | |
881 | |
883 | ############################################################################# |
882 | ############################################################################# |
884 | # command handling &c |
883 | # command handling &c |
… | |
… | |
1725 | my $lock = cf::lock_acquire "map_data:$self->{path}"; |
1724 | my $lock = cf::lock_acquire "map_data:$self->{path}"; |
1726 | |
1725 | |
1727 | return if $self->players; |
1726 | return if $self->players; |
1728 | return if $self->isa ("ext::map_per_player");#d# |
1727 | return if $self->isa ("ext::map_per_player");#d# |
1729 | |
1728 | |
1730 | warn "resetting map ", $self->path;#d# |
1729 | warn "resetting map ", $self->path; |
1731 | |
1730 | |
1732 | $self->in_memory (cf::MAP_SWAPPED); |
1731 | $self->in_memory (cf::MAP_SWAPPED); |
1733 | |
1732 | |
1734 | # need to save uniques path |
1733 | # need to save uniques path |
1735 | unless ($self->{deny_save}) { |
1734 | unless ($self->{deny_save}) { |
… | |
… | |
2481 | warn $@ if $@; |
2480 | warn $@ if $@; |
2482 | _exit 0; |
2481 | _exit 0; |
2483 | } |
2482 | } |
2484 | } |
2483 | } |
2485 | |
2484 | |
2486 | |
|
|
2487 | |
|
|
2488 | ############################################################################# |
2485 | ############################################################################# |
2489 | # the server's init and main functions |
2486 | # the server's init and main functions |
2490 | |
2487 | |
2491 | sub load_facedata($) { |
2488 | sub load_facedata($) { |
2492 | my ($path) = @_; |
2489 | my ($path) = @_; |
… | |
… | |
2563 | sub reload_resources { |
2560 | sub reload_resources { |
2564 | warn "reloading resource files...\n"; |
2561 | warn "reloading resource files...\n"; |
2565 | |
2562 | |
2566 | reload_regions; |
2563 | reload_regions; |
2567 | reload_facedata; |
2564 | reload_facedata; |
|
|
2565 | #reload_archetypes;#d# |
2568 | reload_archetypes; |
2566 | reload_archetypes; |
2569 | reload_treasures; |
2567 | reload_treasures; |
2570 | |
2568 | |
2571 | warn "finished reloading resource files\n"; |
2569 | warn "finished reloading resource files\n"; |
2572 | } |
2570 | } |