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.429 by root, Sat May 3 15:17:13 2008 UTC vs.
Revision 1.432 by root, Mon May 5 22:38:47 2008 UTC

1523 $pl->{deny_save} = 1; 1523 $pl->{deny_save} = 1;
1524 $pl->password ("*"); # this should lock out the player until we nuked the dir 1524 $pl->password ("*"); # this should lock out the player until we nuked the dir
1525 1525
1526 $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1) if $pl->active; 1526 $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1) if $pl->active;
1527 $pl->deactivate; 1527 $pl->deactivate;
1528 my $killer = cf::arch::get "killer_quit"; $pl->killer ($killer); $killer->destroy;
1529 $pl->ob->check_score;
1528 $pl->invoke (cf::EVENT_PLAYER_QUIT); 1530 $pl->invoke (cf::EVENT_PLAYER_QUIT);
1529 $pl->ns->destroy if $pl->ns; 1531 $pl->ns->destroy if $pl->ns;
1530 1532
1531 my $path = playerdir $pl; 1533 my $path = playerdir $pl;
1532 my $temp = "$path~$cf::RUNTIME~deleting~"; 1534 my $temp = "$path~$cf::RUNTIME~deleting~";
2698} 2700}
2699 2701
2700sub prepare_random_map { 2702sub prepare_random_map {
2701 my ($exit) = @_; 2703 my ($exit) = @_;
2702 2704
2703 my $guard = cf::lock_acquire "exit_prepare:$exit";
2704
2705 # all this does is basically replace the /! path by 2705 # all this does is basically replace the /! path by
2706 # a new random map path (?random/...) with a seed 2706 # a new random map path (?random/...) with a seed
2707 # that depends on the exit object 2707 # that depends on the exit object
2708 2708
2709 my $rmp = parse_random_map_params $exit->msg; 2709 my $rmp = parse_random_map_params $exit->msg;
2711 if ($exit->map) { 2711 if ($exit->map) {
2712 $rmp->{region} = $exit->region->name; 2712 $rmp->{region} = $exit->region->name;
2713 $rmp->{origin_map} = $exit->map->path; 2713 $rmp->{origin_map} = $exit->map->path;
2714 $rmp->{origin_x} = $exit->x; 2714 $rmp->{origin_x} = $exit->x;
2715 $rmp->{origin_y} = $exit->y; 2715 $rmp->{origin_y} = $exit->y;
2716
2717 $exit->map->touch;
2716 } 2718 }
2717 2719
2718 $rmp->{random_seed} ||= $exit->random_seed; 2720 $rmp->{random_seed} ||= $exit->random_seed;
2719 2721
2720 my $data = JSON::XS->new->utf8->pretty->canonical->encode ($rmp); 2722 my $data = JSON::XS->new->utf8->pretty->canonical->encode ($rmp);
2724 if (my $fh = aio_open "$meta~", O_WRONLY | O_CREAT, 0666) { 2726 if (my $fh = aio_open "$meta~", O_WRONLY | O_CREAT, 0666) {
2725 aio_write $fh, 0, (length $data), $data, 0; 2727 aio_write $fh, 0, (length $data), $data, 0;
2726 undef $fh; 2728 undef $fh;
2727 aio_rename "$meta~", $meta; 2729 aio_rename "$meta~", $meta;
2728 2730
2731 my $slaying = "?random/$md5";
2732
2733 if ($exit->valid) {
2729 $exit->slaying ("?random/$md5"); 2734 $exit->slaying ("?random/$md5");
2730 $exit->msg (undef); 2735 $exit->msg (undef);
2736 }
2731 } 2737 }
2732} 2738}
2733 2739
2734sub cf::object::player::enter_exit { 2740sub cf::object::player::enter_exit {
2735 my ($self, $exit) = @_; 2741 my ($self, $exit) = @_;
2736 2742
2737 return unless $self->type == cf::PLAYER; 2743 return unless $self->type == cf::PLAYER;
2738 2744
2739 if ($exit->slaying eq "/!") {
2740 #TODO: this should de-fi-ni-te-ly not be a sync-job
2741 # the problem is that $exit might not survive long enough
2742 # so it needs to be done right now, right here
2743 cf::sync_job { prepare_random_map $exit };
2744 }
2745
2746 my $slaying = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path;
2747 my $hp = $exit->stats->hp;
2748 my $sp = $exit->stats->sp;
2749
2750 $self->enter_link; 2745 $self->enter_link;
2751 2746
2752 # if exit is damned, update players death & WoR home-position
2753 $self->contr->savebed ($slaying, $hp, $sp)
2754 if $exit->flag (FLAG_DAMNED);
2755
2756 (async { 2747 (async {
2757 $Coro::current->{desc} = "enter_exit $slaying $hp $sp"; 2748 $Coro::current->{desc} = "enter_exit";
2758 2749
2759 $self->deactivate_recursive; # just to be sure
2760 unless (eval { 2750 unless (eval {
2751 $self->deactivate_recursive; # just to be sure
2752
2753 # random map handling
2754 {
2755 my $guard = cf::lock_acquire "exit_prepare:$exit";
2756
2757 prepare_random_map $exit
2758 if $exit->slaying eq "/!";
2759 }
2760
2761 my $map = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path;
2762 my $x = $exit->stats->hp;
2763 my $y = $exit->stats->sp;
2764
2761 $self->goto ($slaying, $hp, $sp); 2765 $self->goto ($map, $x, $y);
2762 2766
2767 # if exit is damned, update players death & WoR home-position
2768 $self->contr->savebed ($map, $x, $y)
2769 if $exit->flag (cf::FLAG_DAMNED);
2770
2763 1; 2771 1
2764 }) { 2772 }) {
2765 $self->message ("Something went wrong deep within the crossfire server. " 2773 $self->message ("Something went wrong deep within the crossfire server. "
2766 . "I'll try to bring you back to the map you were before. " 2774 . "I'll try to bring you back to the map you were before. "
2767 . "Please report this to the dungeon master!", 2775 . "Please report this to the dungeon master!",
2768 cf::NDI_UNIQUE | cf::NDI_RED); 2776 cf::NDI_UNIQUE | cf::NDI_RED);
3115 3123
3116=cut 3124=cut
3117 3125
3118for ( 3126for (
3119 ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y 3127 ["cf::object" => qw(contr pay_amount pay_player map force_find force_add x y
3120 insert remove inv name archname title slaying race 3128 insert remove inv nrof name archname title slaying race
3121 decrease split destroy)], 3129 decrease split destroy)],
3122 ["cf::object::player" => qw(player)], 3130 ["cf::object::player" => qw(player)],
3123 ["cf::player" => qw(peaceful)], 3131 ["cf::player" => qw(peaceful)],
3124 ["cf::map" => qw(trigger)], 3132 ["cf::map" => qw(trigger)],
3125) { 3133) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines