… | |
… | |
17 | use Coro::Semaphore; |
17 | use Coro::Semaphore; |
18 | use Coro::AIO; |
18 | use Coro::AIO; |
19 | |
19 | |
20 | use Digest::MD5; |
20 | use Digest::MD5; |
21 | use Fcntl; |
21 | use Fcntl; |
22 | use IO::AIO 2.31 (); |
22 | use IO::AIO 2.32 (); |
23 | use YAML::Syck (); |
23 | use YAML::Syck (); |
24 | use Time::HiRes; |
24 | use Time::HiRes; |
25 | |
25 | |
26 | use Event; $Event::Eval = 1; # no idea why this is required, but it is |
26 | use Event; $Event::Eval = 1; # no idea why this is required, but it is |
27 | |
27 | |
… | |
… | |
1086 | |
1086 | |
1087 | Returns the given player object, loading it if necessary (might block). |
1087 | Returns the given player object, loading it if necessary (might block). |
1088 | |
1088 | |
1089 | =cut |
1089 | =cut |
1090 | |
1090 | |
|
|
1091 | sub playerdir($) { |
|
|
1092 | cf::localdir |
|
|
1093 | . "/" |
|
|
1094 | . cf::playerdir |
|
|
1095 | . "/" |
|
|
1096 | . (ref $_[0] ? $_[0]->ob->name : $_[0]) |
|
|
1097 | } |
|
|
1098 | |
1091 | sub path($) { |
1099 | sub path($) { |
1092 | sprintf "%s/%s/%s/%s.pl", |
1100 | my $login = ref $_[0] ? $_[0]->ob->name : $_[0]; |
1093 | cf::localdir, cf::playerdir, |
1101 | |
1094 | (ref $_[0] ? $_[0]->ob->name : $_[0]) x 2 |
1102 | (playerdir $login) . "/$login.pl" |
1095 | } |
1103 | } |
1096 | |
1104 | |
1097 | sub find_active($) { |
1105 | sub find_active($) { |
1098 | $cf::PLAYER{$_[0]} |
1106 | $cf::PLAYER{$_[0]} |
1099 | and $cf::PLAYER{$_[0]}->active |
1107 | and $cf::PLAYER{$_[0]}->active |
… | |
… | |
1142 | $self->{deny_save} = 1; |
1150 | $self->{deny_save} = 1; |
1143 | |
1151 | |
1144 | $cf::PLAYER{$login} = $self; |
1152 | $cf::PLAYER{$login} = $self; |
1145 | |
1153 | |
1146 | $self |
1154 | $self |
|
|
1155 | } |
|
|
1156 | |
|
|
1157 | sub quit_character { |
|
|
1158 | my ($pl) = @_; |
|
|
1159 | |
|
|
1160 | $pl->{deny_save} = 1; |
|
|
1161 | $pl->password ("*"); # this should lock out the player until we nuked the dir |
|
|
1162 | |
|
|
1163 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1) if $pl->active; |
|
|
1164 | $pl->deactivate; |
|
|
1165 | $pl->invoke (cf::EVENT_PLAYER_QUIT); |
|
|
1166 | $pl->ns->destroy if $pl->ns; |
|
|
1167 | |
|
|
1168 | my $path = playerdir $pl; |
|
|
1169 | my $temp = "$path~$cf::RUNTIME~deleting~"; |
|
|
1170 | IO::AIO::aio_rename $path, $temp, sub { |
|
|
1171 | delete $cf::PLAYER{$pl->ob->name}; |
|
|
1172 | $pl->destroy; |
|
|
1173 | |
|
|
1174 | IO::AIO::aio_rmtree $temp; |
|
|
1175 | }; |
1147 | } |
1176 | } |
1148 | |
1177 | |
1149 | =item $player->ext_reply ($msgid, $msgtype, %msg) |
1178 | =item $player->ext_reply ($msgid, $msgtype, %msg) |
1150 | |
1179 | |
1151 | Sends an ext reply to the player. |
1180 | Sends an ext reply to the player. |