--- deliantra/server/ext/login.ext 2007/07/15 08:48:01 1.65 +++ deliantra/server/ext/login.ext 2007/12/28 19:40:22 1.76 @@ -54,6 +54,12 @@ 1 } +sub safe_spot($$$) { + my ($m, $x, $y) = @_; + + scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y) +} + sub enter_map { my ($pl) = @_; @@ -74,10 +80,11 @@ 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; - if ($age >= $MAX_DISCONNECT_TIME) { + if (safe_spot $m, $x, $y) { + # do nothing, this is simply ok without a special scary message + } elsif ($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. " @@ -88,7 +95,7 @@ # kill them. # reminds me of the famous badness 10000 syndrome... $ob->stats->hp (-10000); #] if they survive this they deserved to live - $pl->killer ("cave-in"); + $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. " @@ -98,6 +105,8 @@ cf::NDI_RED ); } + } elsif (safe_spot $m, $x, $y) { + # do nothing, this is simply ok without a special scary message } else { $ob->message ( "You didn't use a bed to reality to leave this realm. This is very dangerous, " @@ -118,10 +127,12 @@ 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~ &)"; + my $temp = "$PLAYERDIR/~$Coro::current~deleting~"; + + cf::fork_call { + rename "$PLAYERDIR/$user", $temp; + system "rm", "-rf", $temp; + }; } cf::client->attach (on_addme => sub { @@ -144,7 +155,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. *** *** @@ -175,6 +186,8 @@ $ns->pl and return $ns->destroy; $ns->async (sub { + $Coro::current->{desc} = "addme init"; + my ($user, $pass); $ns->send_packet ("addme_success"); @@ -212,6 +225,8 @@ check_playing $ns, $user and next; + $Coro::current->{desc} = "addme($user) pass"; + $ns->send_drawinfo ( "Welcome $user, please enter your password now. " . "New users should now choose a password. " @@ -244,6 +259,8 @@ check_playing $ns, $user and next; + $Coro::current->{desc} = "addme($user) check"; + # try to read the user file and check the password if (my $pl = cf::player::find $user) { aio_stat $pl->path and next; @@ -306,6 +323,7 @@ } # the rest of this function is character creation + $Coro::current->{desc} = "addme($user) chargen"; # just to make sure nothing is left over nuke_playerdir $user; @@ -359,10 +377,10 @@ $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"; @@ -389,7 +407,7 @@ Coro::Timer::sleep 0.2; } - $ob->reply (undef, "Welcome to Crossfire!"); + $ob->reply (undef, "Welcome to Deliantra!"); delete $pl->{deny_save}; @@ -479,13 +497,14 @@ ############################################################################# -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); + $Coro::current->{desc} = "player scheduler"; + while () { - $schedule_interval->next; + Coro::EV::timer_once $SCHEDULE_INTERVAL; # this weird form of iteration over values is used because # the hash changes underneath us frequently, and for @@ -499,7 +518,6 @@ eval { if ($pl->{last_save} + $SAVE_TIMEOUT <= $cf::RUNTIME) { - cf::wait_for_tick_begin; $pl->save; unless ($pl->active || $pl->ns) {