… | |
… | |
2 | |
2 | |
3 | # login handling |
3 | # login handling |
4 | |
4 | |
5 | use Fcntl; |
5 | use Fcntl; |
6 | use Coro::AIO; |
6 | use Coro::AIO; |
|
|
7 | |
|
|
8 | our $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 |
9 | sub nuke_str { |
11 | sub 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 | |
55 | sub enter_map { |
57 | sub 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 | $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. " |
77 | . "Fortunately, some friendly dwellers found you, checked your passport, and brought you to safety. " |
95 | . "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...", |
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 { |
|
|
102 | $ob->message ( |
|
|
103 | "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, " |
|
|
105 | . "or monsters suddenly snapping your body. Better use a savebed next time. " |
|
|
106 | . "H<Always apply a bed of reality to disconnect from the server.>", |
79 | cf::NDI_RED |
107 | cf::NDI_RED |
80 | ); |
108 | ); |
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 | } |
109 | } |
89 | } |
110 | } |
90 | } |
111 | } |
91 | |
112 | |
92 | $pl->ob->goto ($map, $x, $y); |
113 | $ob->goto ($map, $x, $y); |
93 | } |
114 | } |
94 | |
115 | |
95 | # delete a player directory, be non-blocking AND synchronous... |
116 | # delete a player directory, be non-blocking AND synchronous... |
96 | # (thats hard, so we crap out and fork). |
117 | # (thats hard, so we crap out and fork). |
97 | sub nuke_playerdir { |
118 | sub nuke_playerdir { |
… | |
… | |
336 | |
357 | |
337 | $ob->set_animation (2); |
358 | $ob->set_animation (2); |
338 | $ob->add_statbonus; |
359 | $ob->add_statbonus; |
339 | |
360 | |
340 | while () { |
361 | while () { |
341 | $ns->send_msg (-1, "chargen-race-title", ucfirst $pl->title); |
362 | $ns->send_msg ("chargen-race-title", ucfirst $pl->title, -1); |
342 | my $msg = $ob->msg; |
363 | my $msg = $ob->msg; |
343 | $msg =~ s/(?<=\S)\n(?=\S)/ /g; |
364 | $msg =~ s/(?<=\S)\n(?=\S)/ /g; |
344 | $ns->send_msg (cf::NDI_BLUE, "chargen-race-description", $msg); |
365 | $ns->send_msg ("chargen-race-description", $msg, cf::NDI_BLUE); |
345 | |
366 | |
346 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
367 | my $res = query $ns, cf::CS_QUERY_SINGLECHAR, |
347 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; |
368 | "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"; |
348 | |
369 | |
349 | last if $res =~ /[dD]/; |
370 | last if $res =~ /[dD]/; |