--- deliantra/server/ext/login.ext 2007/07/05 20:52:22 1.60 +++ deliantra/server/ext/login.ext 2007/09/02 12:37:10 1.70 @@ -5,6 +5,8 @@ use Fcntl; use Coro::AIO; +our $MAX_DISCONNECT_TIME = $cf::CFG{max_disconnect_time} || 3600; + # paranoia function to overwrite a string-in-place sub nuke_str { substr $_[0], 0, (length $_[0]), "x" x length $_[0] @@ -55,41 +57,60 @@ sub enter_map { my ($pl) = @_; + my $ob = $pl->ob; + my ($map, $x, $y) - = $pl->ob->{_link_pos} - ? @{delete $pl->ob->{_link_pos}} - : ($pl->maplevel, $pl->ob->x, $pl->ob->y); + = $ob->{_link_pos} + ? @{delete $ob->{_link_pos}} + : ($pl->maplevel, $ob->x, $ob->y); - $pl->ob->enter_link; + $ob->enter_link; if (my $time = delete $pl->{unclean_save}) { if (my $m = cf::map::find $map) { if ($time < $m->{instantiate_time}) { # the map was reset in the meantime my $age = $cf::RUNTIME - $time; - warn $pl->ob->name, " map reset after logout, logout age $age\n";#d# + + warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# # for now, just go back to savebed ($map, $x, $y) = $pl->savebed; - $pl->ns->send_drawinfo ( - "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " - . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " - . "Better use a savebed next time, much worse things could have happened...", - cf::NDI_RED - ); + if ($age >= $MAX_DISCONNECT_TIME) { + $ob->message ( + "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " + . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " + . "Maybe you can find comfort in the thought that your body was quite satisfying in taste... " + . "H", + cf::NDI_RED + ); + # kill them. + # reminds me of the famous badness 10000 syndrome... + $ob->stats->hp (-10000); #] if they survive this they deserved to live + $pl->killer ("a cave-in"); + } else { + $ob->message ( + "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " + . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " + . "Better use a savebed next time, much worse things could have happened... " + . "H", + cf::NDI_RED + ); + } } else { - $pl->ns->send_drawinfo ( + $ob->message ( "You didn't use a bed to reality to leave this realm. This is very dangerous, " . "as lots of things could happen when you leave by other means, such as cave-ins, " - . "or monsters suddenly snapping your body. Better use a savebed next time.", + . "or monsters suddenly snapping your body. Better use a savebed next time. " + . "H", cf::NDI_RED ); } } } - $pl->ob->goto ($map, $x, $y); + $ob->goto ($map, $x, $y); } # delete a player directory, be non-blocking AND synchronous... @@ -97,10 +118,8 @@ sub nuke_playerdir { my ($user) = @_; - aio_stat "$PLAYERDIR/$user"; - system "cd \Q$PLAYERDIR\E " - . "&& mv \Q$user\E ~\Q$Coro::current\E~deleting~ 2>/dev/null " - . "&& (rm -rf ~\Q$Coro::current\E~deleting~ &)"; + aio_rename "$PLAYERDIR/$user", "$PLAYERDIR/~$Coro::current~deleting~"; + system "rm -rf \Q$PLAYERDIR/~$Coro::current~deleting~\E &"; } cf::client->attach (on_addme => sub { @@ -123,7 +142,7 @@ *** cfclient: use the -cache commandline option. *** cfclient: map will not redraw automatically (bug). *** gcfclient: use -cache commandline option, or enable -*** gcfclient: Client=>Configure=>Map & Image=>Cache Images. +*** gcfclient: Client => Configure => Map & Image => Cache Images. *** jcrossclient: your client is broken, use CFPlus or gcfclient. *** *** @@ -186,6 +205,7 @@ cf::NDI_RED ); } + Coro::Timer::sleep 0.4; } check_playing $ns, $user and next; @@ -206,6 +226,7 @@ . "that cannot be too much to ask for :)", cf::NDI_RED ); + Coro::Timer::sleep 0.4; } # lock this username for the remainder of this login session @@ -296,6 +317,7 @@ "The passwords do not match, please try again.", cf::NDI_RED ); + Coro::Timer::sleep 0.5; next; } @@ -327,16 +349,18 @@ } else { $ob->roll_stats; } + + Coro::Timer::sleep 0.2; } $ob->set_animation (2); $ob->add_statbonus; while () { - $ns->send_msg (-1, "chargen-race-title", ucfirst $pl->title); + $ns->send_msg ("chargen-race-title", ucfirst $pl->title, -1); my $msg = $ob->msg; $msg =~ s/(?<=\S)\n(?=\S)/ /g; - $ns->send_msg (cf::NDI_BLUE, "chargen-race-description", $msg); + $ns->send_msg ("chargen-race-description", $msg, cf::NDI_BLUE); my $res = query $ns, cf::CS_QUERY_SINGLECHAR, "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; @@ -344,6 +368,7 @@ last if $res =~ /[dD]/; $pl->chargen_race_next; + Coro::Timer::sleep 0.2; } $pl->chargen_race_done; @@ -359,6 +384,7 @@ $pl->gender (0); last; } + Coro::Timer::sleep 0.2; } $ob->reply (undef, "Welcome to Crossfire!"); @@ -451,12 +477,13 @@ ############################################################################# -our $SCHEDULE_INTERVAL = 10; # time the player scheduler sleeps between runs -our $SAVE_TIMEOUT = 20; # save players every n seconds +our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs +our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds our $SCHEDULER = cf::async_ext { - my $schedule_interval = Coro::Event->timer (after => 1, interval => $SCHEDULE_INTERVAL); + my $schedule_interval = Coro::Event->timer (after => 1); while () { + $schedule_interval->interval ($SCHEDULE_INTERVAL); $schedule_interval->next; # this weird form of iteration over values is used because @@ -471,7 +498,6 @@ eval { if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { - cf::wait_for_tick_begin; $pl->save; unless ($pl->active || $pl->ns) {