--- deliantra/server/ext/login.ext 2007/10/01 00:55:50 1.73 +++ deliantra/server/ext/login.ext 2008/09/16 16:03:02 1.90 @@ -54,9 +54,28 @@ 1 } +sub safe_spot($) { + my ($pl) = @_; + + my $ob = $pl->ob; + + my $m = $ob->map + or return; + my $x = $ob->x; + my $y = $ob->y; + +# return 0;#d# +# warn join ":", $m->at ($x, $y);#d# +# warn "FOO$m { ".scalar ($m->at ($x, $y))." }\n"; +# return 0; + + scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y) +} + sub enter_map { my ($pl) = @_; + warn $pl->ob->name, ": enter map 1\n";#d# my $ob = $pl->ob; my ($map, $x, $y) @@ -64,53 +83,65 @@ ? @{delete $ob->{_link_pos}} : ($pl->maplevel, $ob->x, $ob->y); + warn $pl->ob->name, ": enter map 2\n";#d# $ob->enter_link; + warn $pl->ob->name, ": enter map 3\n";#d# - 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; + my $m = cf::map::find $map; + my $time = delete $pl->{unclean_save}; + warn $pl->ob->name, ": enter map 4\n";#d# - warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# + if ($time && $m) { + if ($time < $m->{instantiate_time}) { + # the map was reset in the meantime + my $age = $cf::RUNTIME - $time; - # for now, just go back to savebed - ($map, $x, $y) = $pl->savebed; + warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# - 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 - ); - } + 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 + my $killer = cf::arch::get "killer_login"; $pl->killer ($killer); $killer->destroy; } else { + ($map, $x, $y) = $pl->savebed; + $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. " - . "H", + "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 { + $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. " + . "H", + cf::NDI_RED + ); } } - $ob->goto ($map, $x, $y); + warn $pl->ob->name, ": enter map 5\n";#d# + #$ob->goto ($map, $x, $y); + $ob->goto ($map, $x, $y, sub { + warn $pl->ob->name, ": enter map check\n";#d# + $_[0] + }, sub { + warn $pl->ob->name, ": enter map done\n";#d# + }); + warn $pl->ob->name, ": enter map 6\n";#d# + } # delete a player directory, be non-blocking AND synchronous... @@ -142,12 +173,12 @@ *** *** Look at your client preferences: *** -*** CFPlus: all known versions automatically enable the facecache. +*** deliantra: all known versions automatically enable the facecache. *** 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. -*** jcrossclient: your client is broken, use CFPlus or gcfclient. +*** jcrossclient: your client is broken, use deliantra or gcfclient. *** *** EOF @@ -193,7 +224,7 @@ # read username while () { - $user = query $ns, 0, "What is your name?\n:"; + $user = query $ns, 0, "What is your name? (login names are case-sensitive)\n:"; if ($cf::LOGIN_LOCK{$user}) { $ns->send_drawinfo ( @@ -263,6 +294,7 @@ # password matches, wonderful my $pl = cf::player::find $user or next; $pl->connect ($ns); + $pl->ob->flag (cf::FLAG_DEBUG, 1);#d# temp enter_map $pl; last; } elsif (can_cleanup $pl, $mtime) { @@ -361,7 +393,7 @@ $ob->roll_stats; } - Coro::Timer::sleep 0.2; + Coro::Timer::sleep 0.05; } $ob->set_animation (2); @@ -382,6 +414,9 @@ Coro::Timer::sleep 0.2; } + # create the playerdir, if necessary, as chargen_race_done did it before + # presumably because of unique maps + aio_mkdir playerdir $pl, 0770; $pl->chargen_race_done; while () { @@ -398,7 +433,7 @@ Coro::Timer::sleep 0.2; } - $ob->reply (undef, "Welcome to Crossfire!"); + $ob->reply (undef, "Welcome to Deliantra!"); delete $pl->{deny_save}; @@ -449,7 +484,7 @@ $pl->savebed ($bed->map->path, $bed->x, $bed->y); cf::async { $pl->save }; - $pl->killer ("left"); + my $killer = cf::arch::get "killer_logout"; $pl->killer ($killer); $killer->destroy; $ob->check_score; $ob->reply (undef, "In the future, you will wake up here when you die."); @@ -481,7 +516,8 @@ $_->ob->message ("$name left the game.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; } else { $_->ob->message ("$name uncerimoniously disconnected.", cf::NDI_DK_ORANGE | cf::NDI_UNIQUE) for cf::player::list; - $pl->{unclean_save} = $cf::RUNTIME; + $pl->{unclean_save} = $cf::RUNTIME + unless safe_spot $pl; } }, ); @@ -494,10 +530,8 @@ our $SCHEDULER = cf::async_ext { $Coro::current->{desc} = "player scheduler"; - my $schedule_interval = Coro::Event->timer (after => 1, data => cf::WF_AUTOCANCEL); while () { - $schedule_interval->interval ($SCHEDULE_INTERVAL); - $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 @@ -534,13 +568,13 @@ my $a_ = $pl->refcnt;#d# my $b_ = $ob->refcnt;#d# - warn "player-scheduler refcnt ", $ob->name, " pl $pl_ref ob $ob_ref (C pl $a_ ob $b_)\n";#d# + warn "player-scheduler refcnt ", $ob->name, " pl $pl_ref/3 ob $ob_ref/3 (C pl $a_/1 ob $b_/2)\n";#d# } } } }; warn $@ if $@; - Coro::cede; + cf::cede_to_tick; }; } };