--- deliantra/server/ext/login.ext 2007/04/27 17:16:13 1.47 +++ deliantra/server/ext/login.ext 2007/05/26 15:44:03 1.48 @@ -53,18 +53,44 @@ 1 } -sub check_clean_save { +sub enter_map { my ($pl) = @_; + my ($map, $x, $y) + = $pl->ob->{_link_pos} + ? @{delete $pl->ob->{_link_pos}} + : ($pl->maplevel, $pl->ob->x, $pl->ob->y); + + $pl->ob->enter_link; + if (my $time = delete $pl->{unclean_save}) { - $pl->ns->send_drawinfo ( - "You didn't use a savebed 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.", - cf::NDI_RED - ); - #d#TODO + 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# + + # 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 + ); + } else { + $pl->ns->send_drawinfo ( + "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.", + cf::NDI_RED + ); + } + } } + + $pl->ob->goto ($map, $x, $y); } # delete a player directory, be non-blocking AND synchronous... @@ -334,7 +360,7 @@ # password matches, wonderful my $pl = cf::player::find $user or next; $pl->connect ($ns); - check_clean_save $pl; + enter_map $pl; last; } elsif (can_cleanup $pl, $mtime) { Coro::Timer::sleep 1; @@ -407,9 +433,10 @@ $pl->password (crypt $pass, join '', ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[rand 64, rand 64]); nuke_str $pass; $pl->connect ($ns); - my $ob = $pl->ob; + $ob->goto ($pl->maplevel, $ob->x, $ob->y); + while () { $ob->update_stats; $pl->save_stats;