--- deliantra/server/lib/cf.pm 2007/01/07 18:01:10 1.144 +++ deliantra/server/lib/cf.pm 2007/01/07 21:54:59 1.145 @@ -19,7 +19,7 @@ use Digest::MD5; use Fcntl; -use IO::AIO 2.31 (); +use IO::AIO 2.32 (); use YAML::Syck (); use Time::HiRes; @@ -1088,10 +1088,18 @@ =cut +sub playerdir($) { + cf::localdir + . "/" + . cf::playerdir + . "/" + . (ref $_[0] ? $_[0]->ob->name : $_[0]) +} + sub path($) { - sprintf "%s/%s/%s/%s.pl", - cf::localdir, cf::playerdir, - (ref $_[0] ? $_[0]->ob->name : $_[0]) x 2 + my $login = ref $_[0] ? $_[0]->ob->name : $_[0]; + + (playerdir $login) . "/$login.pl" } sub find_active($) { @@ -1146,6 +1154,27 @@ $self } +sub quit_character { + my ($pl) = @_; + + $pl->{deny_save} = 1; + $pl->password ("*"); # this should lock out the player until we nuked the dir + + $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1) if $pl->active; + $pl->deactivate; + $pl->invoke (cf::EVENT_PLAYER_QUIT); + $pl->ns->destroy if $pl->ns; + + my $path = playerdir $pl; + my $temp = "$path~$cf::RUNTIME~deleting~"; + IO::AIO::aio_rename $path, $temp, sub { + delete $cf::PLAYER{$pl->ob->name}; + $pl->destroy; + + IO::AIO::aio_rmtree $temp; + }; +} + =item $player->ext_reply ($msgid, $msgtype, %msg) Sends an ext reply to the player.