ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/login.ext
(Generate patch)

Comparing deliantra/server/ext/login.ext (file contents):
Revision 1.73 by root, Mon Oct 1 00:55:50 2007 UTC vs.
Revision 1.77 by root, Fri Dec 28 19:44:34 2007 UTC

52 ); 52 );
53 53
54 1 54 1
55} 55}
56 56
57sub safe_spot($$$) {
58 my ($m, $x, $y) = @_;
59
60 scalar grep $_->type == cf::SAVEBED, $m->at ($x, $y)
61}
62
57sub enter_map { 63sub enter_map {
58 my ($pl) = @_; 64 my ($pl) = @_;
59 65
60 my $ob = $pl->ob; 66 my $ob = $pl->ob;
61 67
64 ? @{delete $ob->{_link_pos}} 70 ? @{delete $ob->{_link_pos}}
65 : ($pl->maplevel, $ob->x, $ob->y); 71 : ($pl->maplevel, $ob->x, $ob->y);
66 72
67 $ob->enter_link; 73 $ob->enter_link;
68 74
75 my $m = cf::map::find $map;
69 if (my $time = delete $pl->{unclean_save}) { 76 my $time = delete $pl->{unclean_save};
70 if (my $m = cf::map::find $map) { 77
78 if ($time && $m && !safe_spot $m, $x, $y) {
71 if ($time < $m->{instantiate_time}) { 79 if ($time < $m->{instantiate_time}) {
72 # the map was reset in the meantime 80 # the map was reset in the meantime
73 my $age = $cf::RUNTIME - $time; 81 my $age = $cf::RUNTIME - $time;
74 82
75 warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# 83 warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d#
76 84
77 # for now, just go back to savebed
78 ($map, $x, $y) = $pl->savebed; 85 ($map, $x, $y) = $pl->savebed;
79 86
80 if ($age >= $MAX_DISCONNECT_TIME) { 87 if ($age >= $MAX_DISCONNECT_TIME) {
81 $ob->message ( 88 $ob->message (
82 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " 89 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. "
83 . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " 90 . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. "
84 . "Maybe you can find comfort in the thought that your body was quite satisfying in taste... " 91 . "Maybe you can find comfort in the thought that your body was quite satisfying in taste... "
85 . "H<You disconnected too long without having used a savebed.>", 92 . "H<You disconnected too long without having used a savebed.>",
86 cf::NDI_RED 93 cf::NDI_RED
87 ); 94 );
88 # kill them. 95 # kill them.
89 # reminds me of the famous badness 10000 syndrome... 96 # reminds me of the famous badness 10000 syndrome...
90 $ob->stats->hp (-10000); #] if they survive this they deserved to live 97 $ob->stats->hp (-10000); #] if they survive this they deserved to live
91 $pl->killer ("a cave-in"); 98 $pl->killer ("a cave-in");
92 } else {
93 $ob->message (
94 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. "
95 . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. "
96 . "Better use a savebed next time, much worse things could have happened... "
97 . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>",
98 cf::NDI_RED
99 );
100 }
101 } else { 99 } else {
102 $ob->message ( 100 $ob->message (
103 "You didn't use a bed to reality to leave this realm. This is very dangerous, " 101 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. "
104 . "as lots of things could happen when you leave by other means, such as cave-ins, " 102 . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. "
105 . "or monsters suddenly snapping your body. Better use a savebed next time. " 103 . "Better use a savebed next time, much worse things could have happened... "
106 . "H<Always apply a bed of reality to disconnect from the server.>", 104 . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>",
107 cf::NDI_RED 105 cf::NDI_RED
108 ); 106 );
109 } 107 }
108 } else {
109 $ob->message (
110 "You didn't use a bed to reality to leave this realm. This is very dangerous, "
111 . "as lots of things could happen when you leave by other means, such as cave-ins, "
112 . "or monsters suddenly snapping your body. Better use a savebed next time. "
113 . "H<Always apply a bed of reality to disconnect from the server.>",
114 cf::NDI_RED
115 );
110 } 116 }
111 } 117 }
112 118
113 $ob->goto ($map, $x, $y); 119 $ob->goto ($map, $x, $y);
114} 120}
396 last; 402 last;
397 } 403 }
398 Coro::Timer::sleep 0.2; 404 Coro::Timer::sleep 0.2;
399 } 405 }
400 406
401 $ob->reply (undef, "Welcome to Crossfire!"); 407 $ob->reply (undef, "Welcome to Deliantra!");
402 408
403 delete $pl->{deny_save}; 409 delete $pl->{deny_save};
404 410
405 last; 411 last;
406 } 412 }
492our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds 498our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds
493 499
494our $SCHEDULER = cf::async_ext { 500our $SCHEDULER = cf::async_ext {
495 $Coro::current->{desc} = "player scheduler"; 501 $Coro::current->{desc} = "player scheduler";
496 502
497 my $schedule_interval = Coro::Event->timer (after => 1, data => cf::WF_AUTOCANCEL);
498 while () { 503 while () {
499 $schedule_interval->interval ($SCHEDULE_INTERVAL); 504 Coro::EV::timer_once $SCHEDULE_INTERVAL;
500 $schedule_interval->next;
501 505
502 # this weird form of iteration over values is used because 506 # this weird form of iteration over values is used because
503 # the hash changes underneath us frequently, and for 507 # the hash changes underneath us frequently, and for
504 # keeps a direct reference to the value without (in 5.8 perls) 508 # keeps a direct reference to the value without (in 5.8 perls)
505 # keeping a reference, so this is prone to crashes or worse. 509 # keeping a reference, so this is prone to crashes or worse.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines