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.71 by root, Sun Sep 2 12:45:44 2007 UTC vs.
Revision 1.76 by root, Fri Dec 28 19:40:22 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
72 # the map was reset in the meantime 78 # the map was reset in the meantime
73 my $age = $cf::RUNTIME - $time; 79 my $age = $cf::RUNTIME - $time;
74 80
75 warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# 81 warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d#
76 82
77 # for now, just go back to savebed
78 ($map, $x, $y) = $pl->savebed; 83 ($map, $x, $y) = $pl->savebed;
79 84
85 if (safe_spot $m, $x, $y) {
86 # do nothing, this is simply ok without a special scary message
80 if ($age >= $MAX_DISCONNECT_TIME) { 87 } elsif ($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.>",
96 . "Better use a savebed next time, much worse things could have happened... " 103 . "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.>", 104 . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>",
98 cf::NDI_RED 105 cf::NDI_RED
99 ); 106 );
100 } 107 }
108 } elsif (safe_spot $m, $x, $y) {
109 # do nothing, this is simply ok without a special scary message
101 } else { 110 } else {
102 $ob->message ( 111 $ob->message (
103 "You didn't use a bed to reality to leave this realm. This is very dangerous, " 112 "You didn't use a bed to reality to leave this realm. This is very dangerous, "
104 . "as lots of things could happen when you leave by other means, such as cave-ins, " 113 . "as lots of things could happen when you leave by other means, such as cave-ins, "
105 . "or monsters suddenly snapping your body. Better use a savebed next time. " 114 . "or monsters suddenly snapping your body. Better use a savebed next time. "
175 } 184 }
176 185
177 $ns->pl and return $ns->destroy; 186 $ns->pl and return $ns->destroy;
178 187
179 $ns->async (sub { 188 $ns->async (sub {
189 $Coro::current->{desc} = "addme init";
190
180 my ($user, $pass); 191 my ($user, $pass);
181 192
182 $ns->send_packet ("addme_success"); 193 $ns->send_packet ("addme_success");
183 194
184 for (;;) { 195 for (;;) {
211 } 222 }
212 Coro::Timer::sleep 0.4; 223 Coro::Timer::sleep 0.4;
213 } 224 }
214 225
215 check_playing $ns, $user and next; 226 check_playing $ns, $user and next;
227
228 $Coro::current->{desc} = "addme($user) pass";
216 229
217 $ns->send_drawinfo ( 230 $ns->send_drawinfo (
218 "Welcome $user, please enter your password now. " 231 "Welcome $user, please enter your password now. "
219 . "New users should now choose a password. " 232 . "New users should now choose a password. "
220 . "Anything your client lets you enter is fine.", 233 . "Anything your client lets you enter is fine.",
244 } 257 }
245 local $cf::LOGIN_LOCK{$user} = 1; 258 local $cf::LOGIN_LOCK{$user} = 1;
246 259
247 check_playing $ns, $user and next; 260 check_playing $ns, $user and next;
248 261
262 $Coro::current->{desc} = "addme($user) check";
263
249 # try to read the user file and check the password 264 # try to read the user file and check the password
250 if (my $pl = cf::player::find $user) { 265 if (my $pl = cf::player::find $user) {
251 aio_stat $pl->path and next; 266 aio_stat $pl->path and next;
252 my $mtime = (stat _)[9]; 267 my $mtime = (stat _)[9];
253 my $hash = $pl->password; 268 my $hash = $pl->password;
306 next; 321 next;
307 } 322 }
308 } 323 }
309 324
310 # the rest of this function is character creation 325 # the rest of this function is character creation
326 $Coro::current->{desc} = "addme($user) chargen";
311 327
312 # just to make sure nothing is left over 328 # just to make sure nothing is left over
313 nuke_playerdir $user; 329 nuke_playerdir $user;
314 330
315 my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again."; 331 my $pass2 = query $ns, cf::CS_QUERY_HIDEINPUT, "Please type your password again.";
389 last; 405 last;
390 } 406 }
391 Coro::Timer::sleep 0.2; 407 Coro::Timer::sleep 0.2;
392 } 408 }
393 409
394 $ob->reply (undef, "Welcome to Crossfire!"); 410 $ob->reply (undef, "Welcome to Deliantra!");
395 411
396 delete $pl->{deny_save}; 412 delete $pl->{deny_save};
397 413
398 last; 414 last;
399 } 415 }
483 499
484our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs 500our $SCHEDULE_INTERVAL = $cf::CFG{player_schedule_interval} || 10; # time the player scheduler sleeps between runs
485our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds 501our $SAVE_TIMEOUT = $cf::CFG{player_save_interval} || 20; # save players every n seconds
486 502
487our $SCHEDULER = cf::async_ext { 503our $SCHEDULER = cf::async_ext {
488 my $schedule_interval = Coro::Event->timer (after => 1); 504 $Coro::current->{desc} = "player scheduler";
505
489 while () { 506 while () {
490 $schedule_interval->interval ($SCHEDULE_INTERVAL); 507 Coro::EV::timer_once $SCHEDULE_INTERVAL;
491 $schedule_interval->next;
492 508
493 # this weird form of iteration over values is used because 509 # this weird form of iteration over values is used because
494 # the hash changes underneath us frequently, and for 510 # the hash changes underneath us frequently, and for
495 # keeps a direct reference to the value without (in 5.8 perls) 511 # keeps a direct reference to the value without (in 5.8 perls)
496 # keeping a reference, so this is prone to crashes or worse. 512 # keeping a reference, so this is prone to crashes or worse.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines