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.146 by root, Sun Jan 7 23:10:43 2007 UTC vs.
Revision 1.153 by root, Mon Jan 8 23:36:16 2007 UTC

1119 return $cf::PLAYER{$_[0]} || do { 1119 return $cf::PLAYER{$_[0]} || do {
1120 my $login = $_[0]; 1120 my $login = $_[0];
1121 1121
1122 my $guard = cf::lock_acquire "user_find:$login"; 1122 my $guard = cf::lock_acquire "user_find:$login";
1123 1123
1124 $cf::PLAYER{$login} ||= (load_pl path $login or return); 1124 $cf::PLAYER{$_[0]} || do {
1125 my $pl = load_pl path $login
1126 or return;
1127 $cf::PLAYER{$login} = $pl
1128 }
1125 }; 1129 }
1126} 1130}
1127 1131
1128sub save($) { 1132sub save($) {
1129 my ($pl) = @_; 1133 my ($pl) = @_;
1130 1134
1133 my $path = path $pl; 1137 my $path = path $pl;
1134 my $guard = cf::lock_acquire "user_save:$path"; 1138 my $guard = cf::lock_acquire "user_save:$path";
1135 1139
1136 return if $pl->{deny_save}; 1140 return if $pl->{deny_save};
1137 1141
1138 IO::AIO::aio_mkdir playerdir $pl, 0770; 1142 Coro::AIO::aio_mkdir playerdir $pl, 0770;
1139 $pl->{last_save} = $cf::RUNTIME; 1143 $pl->{last_save} = $cf::RUNTIME;
1140 1144
1141 Coro::cede;
1142 $pl->save_pl ($path); 1145 $pl->save_pl ($path);
1143 Coro::cede; 1146 Coro::cede;
1144} 1147}
1145 1148
1146sub new($) { 1149sub new($) {
1167 $pl->invoke (cf::EVENT_PLAYER_QUIT); 1170 $pl->invoke (cf::EVENT_PLAYER_QUIT);
1168 $pl->ns->destroy if $pl->ns; 1171 $pl->ns->destroy if $pl->ns;
1169 1172
1170 my $path = playerdir $pl; 1173 my $path = playerdir $pl;
1171 my $temp = "$path~$cf::RUNTIME~deleting~"; 1174 my $temp = "$path~$cf::RUNTIME~deleting~";
1172 IO::AIO::aio_rename $path, $temp, sub { 1175 Coro::AIO::aio_rename $path, $temp;
1173 delete $cf::PLAYER{$pl->ob->name}; 1176 delete $cf::PLAYER{$pl->ob->name};
1174 $pl->destroy; 1177 $pl->destroy;
1175
1176 IO::AIO::aio_rmtree $temp; 1178 IO::AIO::aio_rmtree $temp;
1177 };
1178} 1179}
1179 1180
1180=item $player->ext_reply ($msgid, $msgtype, %msg) 1181=item $player->ext_reply ($msgid, $msgtype, %msg)
1181 1182
1182Sends an ext reply to the player. 1183Sends an ext reply to the player.
1670=cut 1671=cut
1671 1672
1672sub cf::object::player::goto { 1673sub cf::object::player::goto {
1673 my ($self, $path, $x, $y) = @_; 1674 my ($self, $path, $x, $y) = @_;
1674 1675
1676 $path = new cf::path $path;
1677 $path ne "/" or Carp::cluck ("oy");#d#
1678
1675 $self->enter_link; 1679 $self->enter_link;
1676 1680
1677 (async { 1681 (async {
1678 $path = new cf::path $path;
1679
1680 my $map = cf::map::find $path->as_string; 1682 my $map = cf::map::find $path->as_string;
1681 $map = $map->customise_for ($self) if $map; 1683 $map = $map->customise_for ($self) if $map;
1682 1684
1683# warn "entering ", $map->path, " at ($x, $y)\n" 1685# warn "entering ", $map->path, " at ($x, $y)\n"
1684# if $map; 1686# if $map;
1685 1687
1686 $map or $self->message ("The exit is closed", cf::NDI_UNIQUE | cf::NDI_RED); 1688 $map or $self->message ("The exit to '" . ($path->visible_name) . "' is closed", cf::NDI_UNIQUE | cf::NDI_RED);
1687 1689
1688 $self->leave_link ($map, $x, $y); 1690 $self->leave_link ($map, $x, $y);
1689 })->prio (1); 1691 })->prio (1);
1690} 1692}
1691 1693
2099 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset}; 2101 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset};
2100 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset}; 2102 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset};
2101 2103
2102 if (exists $CFG{mlockall}) { 2104 if (exists $CFG{mlockall}) {
2103 eval { 2105 eval {
2104 $CFG{mlockall} ? &mlockall : &munlockall 2106 $CFG{mlockall} ? eval "mlockall()" : eval "munlockall()"
2105 and die "WARNING: m(un)lockall failed: $!\n"; 2107 and die "WARNING: m(un)lockall failed: $!\n";
2106 }; 2108 };
2107 warn $@ if $@; 2109 warn $@ if $@;
2108 } 2110 }
2109} 2111}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines