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.60 by root, Thu Jul 5 20:52:22 2007 UTC vs.
Revision 1.64 by root, Sat Jul 14 19:27:59 2007 UTC

2 2
3# login handling 3# login handling
4 4
5use Fcntl; 5use Fcntl;
6use Coro::AIO; 6use Coro::AIO;
7
8our $MAX_DISCONNECT_TIME = $cf::CFG{max_disconnect_time} || 3600;
7 9
8# paranoia function to overwrite a string-in-place 10# paranoia function to overwrite a string-in-place
9sub nuke_str { 11sub nuke_str {
10 substr $_[0], 0, (length $_[0]), "x" x length $_[0] 12 substr $_[0], 0, (length $_[0]), "x" x length $_[0]
11} 13}
53} 55}
54 56
55sub enter_map { 57sub enter_map {
56 my ($pl) = @_; 58 my ($pl) = @_;
57 59
60 my $ob = $pl->ob;
61
58 my ($map, $x, $y) 62 my ($map, $x, $y)
59 = $pl->ob->{_link_pos} 63 = $ob->{_link_pos}
60 ? @{delete $pl->ob->{_link_pos}} 64 ? @{delete $ob->{_link_pos}}
61 : ($pl->maplevel, $pl->ob->x, $pl->ob->y); 65 : ($pl->maplevel, $ob->x, $ob->y);
62 66
63 $pl->ob->enter_link; 67 $ob->enter_link;
64 68
65 if (my $time = delete $pl->{unclean_save}) { 69 if (my $time = delete $pl->{unclean_save}) {
66 if (my $m = cf::map::find $map) { 70 if (my $m = cf::map::find $map) {
67 if ($time < $m->{instantiate_time}) { 71 if ($time < $m->{instantiate_time}) {
68 # the map was reset in the meantime 72 # the map was reset in the meantime
69 my $age = $cf::RUNTIME - $time; 73 my $age = $cf::RUNTIME - $time;
74
70 warn $pl->ob->name, " map reset after logout, logout age $age\n";#d# 75 warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d#
71 76
72 # for now, just go back to savebed 77 # for now, just go back to savebed
73 ($map, $x, $y) = $pl->savebed; 78 ($map, $x, $y) = $pl->savebed;
74 79
75 $pl->ns->send_drawinfo ( 80 if ($age >= $MAX_DISCONNECT_TIME) {
81 $ob->message (
76 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " 82 "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. "
84 . "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.>",
86 cf::NDI_RED
87 );
88 # kill them.
89 # reminds me of the famous badness 10000 syndrome...
90 $ob->stats->hp (-10000); #] if they survive this they deserved to live
91 } else {
92 $ob->message (
93 "You didn't use a bed to reality to leave this realm, leaving your body in great danger. "
77 . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " 94 . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. "
78 . "Better use a savebed next time, much worse things could have happened...", 95 . "Better use a savebed next time, much worse things could have happened... "
96 . "H<You disconnected without having used a savebed. When you do that for too long, you might die.>",
97 cf::NDI_RED
98 );
99 }
100 } else {
101 $ob->message (
102 "You didn't use a bed to reality to leave this realm. This is very dangerous, "
103 . "as lots of things could happen when you leave by other means, such as cave-ins, "
104 . "or monsters suddenly snapping your body. Better use a savebed next time. "
105 . "H<Always apply a bed of reality to disconnect from the server.>",
79 cf::NDI_RED 106 cf::NDI_RED
80 ); 107 );
81 } else {
82 $pl->ns->send_drawinfo (
83 "You didn't use a bed to reality to leave this realm. This is very dangerous, "
84 . "as lots of things could happen when you leave by other means, such as cave-ins, "
85 . "or monsters suddenly snapping your body. Better use a savebed next time.",
86 cf::NDI_RED
87 );
88 } 108 }
89 } 109 }
90 } 110 }
91 111
92 $pl->ob->goto ($map, $x, $y); 112 $ob->goto ($map, $x, $y);
93} 113}
94 114
95# delete a player directory, be non-blocking AND synchronous... 115# delete a player directory, be non-blocking AND synchronous...
96# (thats hard, so we crap out and fork). 116# (thats hard, so we crap out and fork).
97sub nuke_playerdir { 117sub nuke_playerdir {
184 . "(only a-z, A-Z and 0-9 are allowed), " 204 . "(only a-z, A-Z and 0-9 are allowed), "
185 . "or is not between 3 and 18 characters in length.", 205 . "or is not between 3 and 18 characters in length.",
186 cf::NDI_RED 206 cf::NDI_RED
187 ); 207 );
188 } 208 }
209 Coro::Timer::sleep 0.4;
189 } 210 }
190 211
191 check_playing $ns, $user and next; 212 check_playing $ns, $user and next;
192 213
193 $ns->send_drawinfo ( 214 $ns->send_drawinfo (
204 $ns->send_drawinfo ( 225 $ns->send_drawinfo (
205 "Try to use at least three characters as your password please, " 226 "Try to use at least three characters as your password please, "
206 . "that cannot be too much to ask for :)", 227 . "that cannot be too much to ask for :)",
207 cf::NDI_RED 228 cf::NDI_RED
208 ); 229 );
230 Coro::Timer::sleep 0.4;
209 } 231 }
210 232
211 # lock this username for the remainder of this login session 233 # lock this username for the remainder of this login session
212 if ($cf::LOGIN_LOCK{$user}) { 234 if ($cf::LOGIN_LOCK{$user}) {
213 $ns->send_drawinfo ( 235 $ns->send_drawinfo (
294 nuke_str $pass2; 316 nuke_str $pass2;
295 $ns->send_drawinfo ( 317 $ns->send_drawinfo (
296 "The passwords do not match, please try again.", 318 "The passwords do not match, please try again.",
297 cf::NDI_RED 319 cf::NDI_RED
298 ); 320 );
321 Coro::Timer::sleep 0.5;
299 next; 322 next;
300 } 323 }
301 324
302 nuke_str $pass2; 325 nuke_str $pass2;
303 326
325 $ob->swap_stats ($res - 1, $swap - 1); 348 $ob->swap_stats ($res - 1, $swap - 1);
326 } 349 }
327 } else { 350 } else {
328 $ob->roll_stats; 351 $ob->roll_stats;
329 } 352 }
353
354 Coro::Timer::sleep 0.2;
330 } 355 }
331 356
332 $ob->set_animation (2); 357 $ob->set_animation (2);
333 $ob->add_statbonus; 358 $ob->add_statbonus;
334 359
342 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; 367 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n";
343 368
344 last if $res =~ /[dD]/; 369 last if $res =~ /[dD]/;
345 370
346 $pl->chargen_race_next; 371 $pl->chargen_race_next;
372 Coro::Timer::sleep 0.2;
347 } 373 }
348 374
349 $pl->chargen_race_done; 375 $pl->chargen_race_done;
350 376
351 while () { 377 while () {
357 last; 383 last;
358 } elsif ($res =~ /^[mM]/) { 384 } elsif ($res =~ /^[mM]/) {
359 $pl->gender (0); 385 $pl->gender (0);
360 last; 386 last;
361 } 387 }
388 Coro::Timer::sleep 0.2;
362 } 389 }
363 390
364 $ob->reply (undef, "Welcome to Crossfire!"); 391 $ob->reply (undef, "Welcome to Crossfire!");
365 392
366 delete $pl->{deny_save}; 393 delete $pl->{deny_save};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines