… | |
… | |
87 | if ($time && $m) { |
87 | if ($time && $m) { |
88 | if ($time < $m->{instantiate_time}) { |
88 | if ($time < $m->{instantiate_time}) { |
89 | # the map was reset in the meantime |
89 | # the map was reset in the meantime |
90 | my $age = $cf::RUNTIME - $time; |
90 | my $age = $cf::RUNTIME - $time; |
91 | |
91 | |
92 | warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
92 | cf::info $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
93 | |
93 | |
94 | if ($age >= $MAX_DISCONNECT_TIME) { |
94 | if ($age >= $MAX_DISCONNECT_TIME) { |
95 | $ob->message ( |
95 | $ob->message ( |
96 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
96 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
97 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
97 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
… | |
… | |
124 | ); |
124 | ); |
125 | } |
125 | } |
126 | } |
126 | } |
127 | |
127 | |
128 | $ob->goto ($map, $x, $y); |
128 | $ob->goto ($map, $x, $y); |
|
|
129 | } |
|
|
130 | |
|
|
131 | sub encode_password { |
|
|
132 | crypt $_[0], |
|
|
133 | join '', |
|
|
134 | ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[(cf::rndm 64), (cf::rndm 64)] |
129 | } |
135 | } |
130 | |
136 | |
131 | # delete a player directory, be non-blocking AND synchronous... |
137 | # delete a player directory, be non-blocking AND synchronous... |
132 | # (that's hard, so we crap out and fork). |
138 | # (that's hard, so we crap out and fork). |
133 | sub nuke_playerdir { |
139 | sub nuke_playerdir { |
… | |
… | |
303 | } |
309 | } |
304 | |
310 | |
305 | nuke_str $pass2; |
311 | nuke_str $pass2; |
306 | |
312 | |
307 | my $pl = cf::player::new $user; |
313 | my $pl = cf::player::new $user; |
308 | $pl->password (crypt $pass, join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]); |
314 | $pl->password (encode_password $pass); |
309 | nuke_str $pass; |
315 | nuke_str $pass; |
310 | $pl->connect ($ns); |
316 | $pl->connect ($ns); |
311 | my $ob = $pl->ob; |
317 | my $ob = $pl->ob; |
312 | |
318 | |
313 | $ob->goto ($pl->maplevel, $ob->x, $ob->y); |
319 | $ob->goto ($pl->maplevel, $ob->x, $ob->y); |
… | |
… | |
385 | $ns->send_msg ("c/motd" => $motd, cf::NDI_CLEAR); |
391 | $ns->send_msg ("c/motd" => $motd, cf::NDI_CLEAR); |
386 | } |
392 | } |
387 | }); |
393 | }); |
388 | }); |
394 | }); |
389 | |
395 | |
|
|
396 | cf::register_command password => sub { |
|
|
397 | my ($pl, $arg) = @_; |
|
|
398 | |
|
|
399 | my (@args) = split /\s+/, $arg; |
|
|
400 | |
|
|
401 | my ($new_pw, $player); |
|
|
402 | |
|
|
403 | if ($pl->flag (cf::FLAG_WIZ)) { |
|
|
404 | ($player, $new_pw) = @args; |
|
|
405 | } else { |
|
|
406 | $new_pw = $args[0]; |
|
|
407 | } |
|
|
408 | |
|
|
409 | if ($pl->flag (cf::FLAG_WIZ) && $player eq '') { |
|
|
410 | $pl->message ( |
|
|
411 | "Usage: password <player> [<new password>]", |
|
|
412 | cf::NDI_UNIQUE | cf::NDI_REPLY); |
|
|
413 | return; |
|
|
414 | } elsif (!$pl->flag (cf::FLAG_WIZ) && $new_pw eq '') { |
|
|
415 | $pl->message ( |
|
|
416 | "Usage: password <new password>", |
|
|
417 | cf::NDI_UNIQUE | cf::NDI_REPLY); |
|
|
418 | return; |
|
|
419 | } |
|
|
420 | |
|
|
421 | if ($player ne '' && $pl->flag (cf::FLAG_WIZ)) { |
|
|
422 | unless ($new_pw ne '') { |
|
|
423 | $new_pw = |
|
|
424 | join '', |
|
|
425 | map { ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[(cf::rndm 64)] } |
|
|
426 | 1..9; |
|
|
427 | } |
|
|
428 | |
|
|
429 | cf::async { |
|
|
430 | my $plc = cf::player::find $player; |
|
|
431 | if ($plc) { |
|
|
432 | $plc->password (encode_password $new_pw); |
|
|
433 | $pl->message ( |
|
|
434 | "Ok, changed password of '$player' to '$new_pw'!", |
|
|
435 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
|
|
436 | } else { |
|
|
437 | $pl->message ( |
|
|
438 | "Fail! Couldn't set password for '$player', " |
|
|
439 | . "he doesn't seem to exist!", |
|
|
440 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
|
|
441 | } |
|
|
442 | }; |
|
|
443 | } else { |
|
|
444 | my $change = delete $pl->{password_change}; |
|
|
445 | |
|
|
446 | if ($change && (time - $change->[0]) < 60) { |
|
|
447 | $pl->message ( |
|
|
448 | "Ok, changed your password!", |
|
|
449 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
|
|
450 | $pl->contr->password (encode_password $new_pw); |
|
|
451 | |
|
|
452 | } else { |
|
|
453 | $pl->message ( |
|
|
454 | "Ok, please confirm your new password by sending " |
|
|
455 | . "the command again within one minute!", |
|
|
456 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
|
|
457 | $pl->{password_change} = [time, $new_pw]; |
|
|
458 | } |
|
|
459 | } |
|
|
460 | }; |
|
|
461 | |
390 | cf::register_command quit => sub { |
462 | cf::register_command quit => sub { |
391 | my ($ob, $arg) = @_; |
463 | my ($ob, $arg) = @_; |
392 | |
464 | |
393 | $ob->send_msg (undef, |
465 | $ob->send_msg (undef, |
394 | "Quitting will delete your character PERMANENTLY: It will be gone forever and any progress will be lost. " |
466 | "Quitting will delete your character PERMANENTLY: It will be gone forever and any progress will be lost. " |
… | |
… | |
405 | if ($_[0] !~ /^[yY]/) { |
477 | if ($_[0] !~ /^[yY]/) { |
406 | $ob->send_msg (undef, "Ok, not not quitting then.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
478 | $ob->send_msg (undef, "Ok, not not quitting then.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
407 | } else { |
479 | } else { |
408 | $ob->send_msg (undef, "Ok, quitting, hope to see you again.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
480 | $ob->send_msg (undef, "Ok, quitting, hope to see you again.", cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
409 | $pl->ns->flush; |
481 | $pl->ns->flush; |
|
|
482 | cf::async { |
|
|
483 | ext::highscore::check $pl->ob; |
410 | cf::async { $pl->quit_character }; |
484 | $pl->quit_character; |
|
|
485 | }; |
411 | } |
486 | } |
412 | }); |
487 | }); |
413 | }; |
488 | }; |
414 | |
489 | |
415 | cf::object->attach ( |
490 | cf::object->attach ( |