… | |
… | |
143 | } else { |
143 | } else { |
144 | return $token eq crypt $pass, $token; |
144 | return $token eq crypt $pass, $token; |
145 | } |
145 | } |
146 | } |
146 | } |
147 | |
147 | |
148 | # delete a player directory, be non-blocking AND synchronous... |
148 | # delete a player directory |
149 | # (that's hard, so we crap out and fork). |
|
|
150 | sub nuke_playerdir { |
149 | sub nuke_playerdir { |
151 | my ($user) = @_; |
150 | my ($user) = @_; |
152 | |
151 | |
|
|
152 | my $lock = cf::lock_acquire "ext::login::nuke_playerdir"; |
|
|
153 | |
153 | my $temp = "$PLAYERDIR/~$Coro::current~deleting~"; |
154 | my $temp = "$PLAYERDIR/~$Coro::current~deleting~"; |
154 | |
|
|
155 | cf::fork_call { |
|
|
156 | rename "$PLAYERDIR/$user", $temp; |
155 | aio_rename "$PLAYERDIR/$user", $temp; |
157 | system "rm", "-rf", $temp; |
156 | IO::AIO::aio_rmtree $temp; |
158 | }; |
|
|
159 | } |
157 | } |
160 | |
158 | |
161 | cf::client->attach (on_addme => sub { |
159 | cf::client->attach (on_addme => sub { |
162 | my ($ns) = @_; |
160 | my ($ns) = @_; |
163 | |
161 | |
… | |
… | |
303 | |
301 | |
304 | # the rest of this function is character creation |
302 | # the rest of this function is character creation |
305 | $Coro::current->{desc} = "addme($user) chargen"; |
303 | $Coro::current->{desc} = "addme($user) chargen"; |
306 | |
304 | |
307 | # just to make sure nothing is left over |
305 | # just to make sure nothing is left over |
|
|
306 | # normally, nothing is there. |
308 | nuke_playerdir $user; |
307 | nuke_playerdir $user; |
309 | |
308 | |
310 | my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again."; |
309 | my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again."; |
311 | |
310 | |
312 | if ($pass2 ne $pass) { |
311 | if ($pass2 ne $pass) { |
… | |
… | |
488 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to PERMANENTLY delete your character and all associated data (y/n)?", sub { |
487 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to PERMANENTLY delete your character and all associated data (y/n)?", sub { |
489 | if ($_[0] !~ /^[yY]/) { |
488 | if ($_[0] !~ /^[yY]/) { |
490 | $ob->send_msg (undef, "Ok, not not quitting then.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
489 | $ob->send_msg (undef, "Ok, not not quitting then.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
491 | } else { |
490 | } else { |
492 | $ob->send_msg (undef, "Ok, quitting, hope to see you again.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
491 | $ob->send_msg (undef, "Ok, quitting, hope to see you again.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
493 | $pl->ns->flush; |
|
|
494 | cf::async { |
492 | cf::async { |
495 | ext::highscore::check $pl->ob; |
|
|
496 | $pl->quit_character; |
493 | $pl->quit_character; |
497 | }; |
494 | }; |
498 | } |
495 | } |
499 | }); |
496 | }); |
500 | }; |
497 | }; |
… | |
… | |
508 | |
505 | |
509 | my $pl = $ob->contr; |
506 | my $pl = $ob->contr; |
510 | |
507 | |
511 | # update respawn position |
508 | # update respawn position |
512 | $pl->savebed ($bed->map->path, $bed->x, $bed->y); |
509 | $pl->savebed ($bed->map->path, $bed->x, $bed->y); |
513 | cf::async { $pl->save }; |
|
|
514 | |
510 | |
|
|
511 | cf::async { |
515 | my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy; |
512 | my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy; |
516 | ext::highscore::check $ob; |
513 | ext::highscore::check $ob; |
517 | |
514 | |
|
|
515 | $pl->save; |
|
|
516 | |
518 | $ob->send_msg ($cf::SAY_CHANNEL => "In the future, you will wake up here when you die.", cf::NDI_DEF | cf::NDI_REPLY); |
517 | $ob->send_msg ($cf::SAY_CHANNEL => "In the future, you will wake up here when you die.", cf::NDI_DEF | cf::NDI_REPLY); |
519 | |
518 | |
520 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
519 | $pl->ns->query (cf::CS_QUERY_SINGLECHAR, "Do you want to continue playing (y/n)?", sub { |
521 | if ($_[0] !~ /^[yY]/) { |
520 | if ($_[0] !~ /^[yY]/) { |
522 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1); |
521 | $pl->invoke (cf::EVENT_PLAYER_LOGOUT, 1); |
523 | $pl->deactivate; |
522 | $pl->deactivate; |
524 | $pl->ns->destroy; |
523 | $pl->ns->destroy; |
525 | } else { |
524 | } |
526 | cf::async { $pl->save }; |
|
|
527 | } |
525 | }); |
528 | }); |
526 | }; |
529 | }, |
527 | }, |
530 | ); |
528 | ); |
531 | |
529 | |
532 | cf::player->attach ( |
530 | cf::player->attach ( |
533 | on_login => sub { |
531 | on_login => sub { |